在我以这种方式声明一个变量之后:
#include <thread> namespace thread_space { thread_local int s; } //etc.
我试图使用’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.
如果我尝试在Linux上编译相同的代码,GCC 4.8.1将使用相同的标志,我将获得一个运行可执行文件.我在运行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’s clang (503.0.38)和normal released one做了一个差异,发现了以下区别:
.Case("cxx_thread_local",- LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported() && - !PP.getTargetInfo().getTriple().isOSDarwin()) + LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported())
所以我认为这是一个苹果的ang子版本的错误(或者它们在目的地保留在这里 – 但仍然很奇怪,因为-v说基于3.4).
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。