Can you embed #ifdef and #endif?
For example:
#ifdef B
run1();
#ifdef C
run2();
#endif
#endif
Desired result is run2() only occurs if both B and C are defined
Can you embed #ifdef and #endif?
For example:
#ifdef B
run1();
#ifdef C
run2();
#endif
#endif
Desired result is run2() only occurs if both B and C are defined
Yes you can.
See the official GCC documentation for details.
The controlled text inside of a conditional can include preprocessing directives. They are executed only if the conditional succeeds. You can nest conditional groups inside other conditional groups, but they must be completely nested. In other words, ‘#endif’ always matches the nearest ‘#ifdef’ (or ‘#ifndef’, or ‘#if’). Also, you cannot start a conditional group in one file and end it in another.