如何在 Mac OSX clang 上获得对 thread_local 的支持?

How to get support for thread_local on Mac OSX clang?

this answer 所示,来自 Xcode on Mac OSX 的 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
  ^

Xcode 8(及更高版本)提供的 clang 版本支持 thread_local 关键字;查看讨论 .

如果thread_local 在您的编译器版本中不可用。