If a value is defined as
#define M_40 40
Is the size the same as a short (2 bytes) or is it as a char (1 byte) or int (4 bytes)?
Is the size dependent on whether you are 32-bit or 64-bit?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
#definehas no size as it’s not a type but a plain text substitution into your C++ code.#defineis a preprocessing directive and it runs before your code even begins to be compiled .The size in C++ code after substitution is whatever the size is of what C++ expression or code you have there. For example if you suffix with
Llike102Lthen it is seen a long, otherwise with no suffix, just an int. So 4 bytes on x86 and x64 probably, but this is compiler dependent.Perhaps the C++ standard’s Integer literal section will clear it up for you (Section 2.13.1-2 of the C++03 standard):