Question

I have several inline static C functions. And I call Objective-C codes including [-release].

The problem is I have to compile this code both of ARC or non-ARC targets. So I think I need conditional compilation by predefined compiler flag. What flag should I use for this?

Was it helpful?

Solution

From http://lists.apple.com/archives/xcode-users/2011/Aug/msg00252.html:

The LLVM Compiler's checks are called __has_feature. ARC is one of the features you can check for.

#ifndef __has_feature
// not LLVM Compiler
#define __has_feature(x) 0
#endif

#if __has_feature(objc_arc)
// compiling with ARC
#else
// compiling without ARC
#endif
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top