【问题标题】:How to get support for thread_local on Mac OSX clang?如何在 Mac OSX clang 上获得对 thread_local 的支持?
【发布时间】:2016-01-26 07:12:15
【问题描述】:

如this answer 所示,Mac OSX 上的 Xcode 中的 clang 不支持 thread_local 存储,即使设置了 C++11 标志。即使在最新版本上,Apple LLVM 版本 7.0.0 (clang-700.1.76),目标:x86_64-apple-darwin15.0.0,线程模型:posix,不支持thread_local:

../../src/dir/sysArch.h:1505:3: error: thread-local storage is not supported
                                       for the current target
  thread_local
  ^

【问题讨论】:

  • 您可以改用开源版本的clang吗?我面临同样的问题。 2016 年底。

标签: c++ xcode c++11 clang thread-local


【解决方案1】:

Xcode 8(及更高版本)提供的 clang 版本支持 thread_local 关键字;见讨论here。

【讨论】:

    【解决方案2】:

    如果thread_local 在您的编译器版本中不可用,您可以使用旧方法使用pthread_getspecific() 等来实现线程本地存储(或在Objective-C 中NSThread 的线程字典)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-11
      • 2015-10-25
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      • 2021-05-08
      • 2016-08-20
      相关资源
      最近更新 更多