在我以这种方式声明变量之后:
#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附带的那个).谁能解释一下我做错了什么?谢谢!!