If I define
#if SOMETHING
#endif
and I have not defined SOMETHING anywhere. Would the code inside #if compile ?
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.
When the name used in the argument expression of
#ifis not defined as a macro (after all other macro replacement is finished), it is replaced with0. This means that your#if SOMETHINGwill be interpreted as#if 0. The code under#ifwill be removed by preprocessor.The rule applies to more complex expressions as well. You can do
which will evaluate to
#if 42, since unknown nameBis interpreted as0