Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid preprocessing directive for #elseifdef in Xcode

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?

like image 920
Lukasz Avatar asked Feb 27 '12 08:02

Lukasz


2 Answers

Is #elseifdef directive not supported by Xcode?

It is not. Use this instead:

#elif defined(SOME_ANOTHER_TARGET_FLAG)
like image 124
justin Avatar answered Oct 10 '22 20:10

justin


Its not supported as indicated by the error message. See 'the C preprocessor' - https://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.2.1/cpp/index.html#//apple_ref/doc/uid/TP40007092 (conditional compilation).

like image 37
hburde Avatar answered Oct 10 '22 21:10

hburde