Can I use an ifdef in a #define line
C Interview Questions and Answers
(Continued from previous question...)
Can I use an ifdef in a #define line
Q: Can I use an #ifdef in a #define line, to define something two different ways, like this?
#define a b \
#ifdef whatever
c d
#else
e f g
#endif
A: No. You can't ``run the preprocessor on itself,'' so to speak. What you can do is use one of two completely separate #define lines, depending on the #ifdef setting:
#ifdef whatever
#define a b c d
#else
#define a b e f g
#endif
(Continued on next question...)
Other Interview Questions
|