简体   繁体   English

Xcode预编译头中为C ++语言定义的预处理器是什么?

[英]What is the preprocessor define for C++ language in Xcode precompile header?

In my Prefix.pch file I am using __OBJC__ preprocessor define for compilation of Objective C headers. 在我的Prefix.pch文件中,我正在使用__OBJC__预处理程序定义来编译Objective C标头。 What is the equivalent for compilation of C++ headers? C ++标头的编译等效于什么?

#ifdef __OBJC__
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
#endif

There is a standard preprocessor constant, __cplusplus . 有一个标准的预处理器常量__cplusplus Its value is expanded to version number of C++ standard being used: 其值扩展为正在使用的C ++标准的版本号:

__cplusplus __cplusplus

denotes the version of C++ standard that is being used, expands to value 199711L (until C++11), 201103L (C++11), 201402L (C++14), or 201703L (C++17) 表示正在使用的C ++标准版本,扩展为值199711L(直到C ++ 11),201103L(C ++ 11),201402L(C ++ 14)或201703L(C ++ 17)

Source: cppreference 资料来源: cppreference

So, you can write, for example: 因此,您可以编写例如:

#ifdef __cplusplus
  #if __cplusplus >= 201103L
    // include new stuff
  #else
    // use legacy features
  #endif
#endif

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM