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

✍: Guest

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

2016-02-03, 719👍, 0💬