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

I am trying to turn off automatic crash log reports when one or both of the two definitions are set: DEBUG for our debug builds and INTERNATIONAL for international builds. However, when I try to do this in the case of #ifndef , I get an Extra tokens at end of #ifndef directive warning, and working with the specified DEBUG will trigger Crittercism.

 #ifndef defined(INTERNATIONAL) || defined(DEBUG) // WE NEED TO REGISTER WITH THE CRITTERCISM APP ID ON THE CRITTERCISM WEB PORTAL [Crittercism enableWithAppID:@"hahayoudidntthinkidleavetherealonedidyou"]; #else DDLogInfo(@"Crash log reporting is unavailable in the international build"); // Since Crittercism is disabled for international builds, go ahead and // registers our custom exception handler. It not as good sadly NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); DDLogInfo(@"Registered exception handler"); #endif 

This truth table shows what I expect:

 INTL defined | DEBUG defined | Crittercism Enabled F | F | T F | T | F T | F | F T | T | F 

This worked before when it was just #ifndef INTERNATIONAL . I also tried without defined(blah) and with parentheses around the entire statement (same warning and error, respectively).

How do I get the behavior that I want to get from the compiler?

+7
ios objective-c conditional-compilation
source share
1 answer

Do you want to:

 #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 
+13
source share

All Articles