[英]What is the preprocessor define for C++ language in Xcode precompile header?
在我的Prefix.pch
文件中,我正在使用__OBJC__
预处理程序定义来编译Objective C标头。 C ++标头的编译等效于什么?
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
有一个标准的预处理器常量__cplusplus
。 其值扩展为正在使用的C ++标准的版本号:
__cplusplus
表示正在使用的C ++标准版本,扩展为值199711L(直到C ++ 11),201103L(C ++ 11),201402L(C ++ 14)或201703L(C ++ 17)
资料来源: cppreference
因此,您可以编写例如:
#ifdef __cplusplus
#if __cplusplus >= 201103L
// include new stuff
#else
// use legacy features
#endif
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.