【问题标题】:How to determine compiler is currently in ARC mode?如何确定编译器当前处于 ARC 模式?
【发布时间】:2012-01-15 19:42:48
【问题描述】:

我有几个inline static C 函数。我调用 Objective-C 代码,包括[-release]

问题是我必须编译 ARC 或非 ARC 目标的代码。所以我认为我需要通过预定义的编译器标志进行条件编译。我应该为此使用什么标志?

【问题讨论】:

    标签: automatic-ref-counting clang compiler-flags


    【解决方案1】:

    来自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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多