有没有办法测试(使用预处理器)是否在Xcode 4.4或更新版本下编译文件?或者,更具体地说,测试编译器是否会自动@synthesize
属性并抛出编译错误?
答案 0 :(得分:4)
您可以使用它来测试该功能:
#if (defined(__clang__) && __has_feature(objc_default_synthesize_properties))
#warning Got it
#else
#error omg no auto synthesis
#endif
此处记录了完整的功能列表:http://clang.llvm.org/docs/LanguageExtensions.html
答案 1 :(得分:2)
因为这是使用4.x版本的LLVM编译器提供的,所以您应该能够使用以下内容来测试是否存在足够新的版本:
#if __clang__ && (__clang_major__ >= 4)
// New version code here
#else
// Fallback code for older version here
#endif