相关疑难解决方法(0)

为什么Apple clang在'官方'clang支持时不允许使用C++ 11 thread_local

下面是一个简单的程序,它在共享库中使用非POD类型的C++ 11 thread_local变量进行测试.

如果我使用自制软件,这很好用:

> /usr/local/Cellar/llvm/3.5.0_2/bin/clang --version                                          
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

> cmake .. -G Ninja -DCMAKE_C_COMPILER=/usr/local/Cellar/llvm/3.5.0_2/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm/3.5.0_2/bin/clang++
-- The C compiler identification is Clang 3.5.0
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Ninja
-- …
Run Code Online (Sandbox Code Playgroud)

xcode clang c++11

23
推荐指数
1
解决办法
1万
查看次数

c ++线程本地存储clang-503.0.40(Mac OSX)

在我以这种方式声明变量之后:

   #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附带的那个).谁能解释一下我做错了什么?谢谢!!

macos xcode clang thread-local-storage c++11

16
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++11 ×2

clang ×2

xcode ×2

macos ×1

thread-local-storage ×1