Invalid preprocessing directive for #elseifdef in Xcode

Lukasz picture Lukasz · Feb 27, 2012 · Viewed 11.6k times · Source

Why:

 #ifdef SOME_TARGET_FLAG     
      <some code here>
    #elseifdef SOME_ANOTHER_TARGET_FLAG
      <some another code here>
    #endif

produces "Invalid preprocessing directive" preprocess compilation error?

SOME_TARGET_FLAG and SOME_ANOTHER_TARGET_FLAG are just some "Other C-flags" defined in target build settings (-D<FLAG_NAME> pattern).

Is #elseifdef directive not supported by Xcode?

Answer

justin picture justin · Feb 27, 2012

Is #elseifdef directive not supported by Xcode?

It is not. Use this instead:

#elif defined(SOME_ANOTHER_TARGET_FLAG)