During one review I came across a piece of code like the following :
#if defined(x) || y
What does the above statement mean ? Will the condition execute properly ?
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.
Yes it is valid.
Here is what the Standard (C99) says in 6.10p1:
the
definedoperator is seen as unary operator part of a constant expression (6.10.1p1).In your example, the condition is evaluated as true if the macro
xis defined OR ifyis defined and different than0