pie*_*r94 16 macos xcode clang thread-local-storage c++11
在我以这种方式声明变量之后:
#include <thread>
namespace thread_space
{
thread_local int s;
} //etc.
Run Code Online (Sandbox Code Playgroud)
我试图使用'g ++ -std = c ++ 0x -pthread [sourcefile]'编译我的代码.我收到以下错误:
example.C:6:8: error: thread-local storage is unsupported for the current target
static thread_local int s;
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用GCC 4.8.1在Linux上使用相同的标志编译相同的代码,我会得到一个正常运行的可执行文件.我在运行OSX 10.9.3的MacBook Pro上使用了clang-503.0.40(Xcode 5.1.1附带的那个).谁能解释一下我做错了什么?谢谢!!
试试clang++ -stdlib=libc++ -std=c++11.OS X过时的libstdc ++不支持TLS.
编辑
好的,这适用于普通的clang版本,但不适用于Xcode版本.
我对Apple的铿锵声(503.0.38)和正常发布的铿锵声做了一个差异,发现了以下不同之处:
.Case("cxx_thread_local",
- LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported() &&
- !PP.getTargetInfo().getTriple().isOSDarwin())
+ LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported())
Run Code Online (Sandbox Code Playgroud)
所以我认为这是Apple的clang版本中的一个错误(或者他们故意将它保留在那里 - 但仍然很奇怪,因为-v基于3.4).
| 归档时间: |
|
| 查看次数: |
13773 次 |
| 最近记录: |