Is there a way for me to do the following in C?
#ifdef MACRO_1 && MACRO_2
...
#endif
Writing this directly causes a compilation error.
Is there a way for me to do the following in C?
#ifdef MACRO_1 && MACRO_2
...
#endif
Writing this directly causes a compilation error.
This SO answer on - Is #if defined MACRO equivalent to #ifdef MACRO? explains it wonderfully.
Instead of using #ifdef
, use #if defined(...)
. Since defined(...)
will evaluate to a 0 or 1, it'll behave as a normal #if
Code would look like the following:
#if defined(MACRO_1) && defined(MACRO_2)
...
#endif