Isaac
Isaac

Reputation: 10834

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?

Upvotes: 2

Views: 435

Answers (2)

justin
justin

Reputation: 104708

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

Upvotes: 4

Brad Larson
Brad Larson

Reputation: 170317

Because this was made available with the 4.x versions of the LLVM compiler, you should be able to use the following to test for the presence of a new enough version:

#if __clang__ && (__clang_major__ >= 4)
 // New version code here
#else
 // Fallback code for older version here
#endif

Upvotes: 2

Related Questions