How can I add a \'or\' condition in #ifdef ?
I have tried:
#ifdef CONDITION1 || CONDITION2
#endif
#if defined(CONDITION1) || defined(CONDITION2)
should work. :)
#ifdef
is a bit less typing, but doesn't work well with more complex conditions
May use this-
#if defined CONDITION1 || defined CONDITION2
//your code here
#endif
This also does the same-
#if defined(CONDITION1) || defined(CONDITION2)
//your code here
#endif
Further-
#if defined CONDITION1 && defined CONDITION2
#if defined CONDITION1 ^ defined CONDITION2
#if defined CONDITION1 && !defined CONDITION2
I am really OCD about maintaining strict column limits, and not a fan of "\" line continuation because you can't put a comment after it, so here is my method.
//|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|//
#ifdef CONDITION_01 //| |//
#define TEMP_MACRO //| |//
#endif //| |//
#ifdef CONDITION_02 //| |//
#define TEMP_MACRO //| |//
#endif //| |//
#ifdef CONDITION_03 //| |//
#define TEMP_MACRO //| |//
#endif //| |//
#ifdef TEMP_MACRO //| |//
//|- -- -- -- -- -- -- -- -- -- -|//
printf("[IF_CONDITION:(1|2|3)]\n");
//|- -- -- -- -- -- -- -- -- -- -|//
#endif //| |//
#undef TEMP_MACRO //| |//
//|________________________________________|//