2012-01-15 19 views
2

我有幾個inline static C函數。我稱之爲Objective-C代碼,包括[-release]如何確定編譯器目前處於ARC模式?

問題是我必須編譯這個代碼既ARC或非ARC目標。所以我認爲我需要通過預定義的編譯器標誌進行條件編譯。我應該使用哪個標誌?

回答

2

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

的LLVM編譯器的檢查,被稱爲__has_feature。 ARC是您可以檢查的 功能之一。

#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 
相關問題