Xcode 中 #elseifdef 的预处理指令无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9461927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:27:09  来源:igfitidea点击:

Invalid preprocessing directive for #elseifdef in Xcode

objective-cxcodec-preprocessorpreprocessor-directive

提问by Lukasz

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).

SOME_TARGET_FLAG 和 SOME_ANOTHER_TARGET_FLAG 只是在目标构建设置(-D<FLAG_NAME>模式)中定义的一些“其他 C 标志” 。

Is #elseifdefdirective not supported by Xcode?

#elseifdef指令不被支持的Xcode?

回答by justin

Is #elseifdef directive not supported by Xcode?

Xcode 不支持 #elseifdef 指令吗?

It is not. Use this instead:

它不是。改用这个:

#elif defined(SOME_ANOTHER_TARGET_FLAG)

回答by hburde

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).

如错误消息所示,它不受支持。请参阅“C 预处理器” - https://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.2.1/cpp/index.html#//apple_ref/doc/uid/TP40007092(条件编译)。