Search code examples
xcodexcode4clangc-preprocessor

Preprocessor check for Xcode 4.4 or newer


Is there a way to test (with the preprocessor) if a file is being compiled under Xcode 4.4 or newer? Or, more particularly, to test if the compiler will automatically @synthesize properties and throw a compile error if not?


Solution

  • you can use this to test for the feature:

    #if (defined(__clang__) && __has_feature(objc_default_synthesize_properties))
    #warning Got it
    #else
    #error omg no auto synthesis
    #endif
    

    the full list of features is documented here: http://clang.llvm.org/docs/LanguageExtensions.html