how to use #ifdef with an OR condition? how to use #ifdef with an OR condition? c c

how to use #ifdef with an OR condition?


Like this

#if defined(LINUX) || defined(ANDROID)


OR condition in #ifdef

#if defined LINUX || defined ANDROID// your code here#endif /* LINUX || ANDROID */

or-

#if defined(LINUX) || defined(ANDROID)// your code here#endif /* LINUX || ANDROID */

Both above are the same, which one you use simply depends on your taste.


P.S.: #ifdef is simply the short form of #if defined, however, does not support complex condition.


Further-

  • AND: #if defined LINUX && defined ANDROID
  • XOR: #if defined LINUX ^ defined ANDROID