Conditional compilation with ifndef and || doesn't catch second case Conditional compilation with ifndef and || doesn't catch second case objective-c objective-c

Conditional compilation with ifndef and || doesn't catch second case


You want:

#if !defined(INTERNATIONAL) && !defined(DEBUG)    // neither defined - setup Crittercism#else    // one or both defined#endif

Or you can do:

#if defined(INTERNATIONAL) || defined(DEBUG)    // one or both defined#else    // neither defined - setup Crittercism#endif


I just found one post Conditional Compilation which can be better explained the differences between #if/#elif and #ifdef/#ifndeffrom syntax level:

  • #if constant-expression newline
  • #ifdef identifier newline
  • #ifndef identifier newline
  • #else newline
  • #elif constant-expression newline
  • #endif newline

So here we can see #ifndef must be followed by 'identifier', that was often the macro defined by #define directive, or @rmaddy said 'a single value'.

But if can be followed by 'constant-expression' so that the conditional expression defined(INTERNATIONAL) || defined(DEBUG) or !defined(INTERNATIONAL) && !defined(DEBUG) can be used.