clang不知道std :: atomic_bool,但XCode [英] clang doesn't know std::atomic_bool, but XCode does

查看:680
本文介绍了clang不知道std :: atomic_bool,但XCode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译声明一个类型为std :: atomic_bool的变量的C ++ 11代码。这是在Mac OS 10.8.2与clang:

  clang --version 
苹果clang版本4.1 Apple / clang-421.11.66)(基于LLVM 3.1svn)
目标:x86_64-apple-darwin12.2.0
线程模型:posix

clang抱怨std :: atomic_bool:

  clang ++ -c -stdlib = libc ++ -msse4 -std = c ++ 11 -Wno-unused-parameter -I。 -o query.o query.cpp 
在从query.cpp中包含的文件中:1:
[...]
./threadutils.h:33:10:错误:没有类型命名'atomic_bool'in namespace'std';你是说atomic_long吗?
std :: atomic_bool work;但是,同一个文件在XCode项目中使用相同的编译器编译得很好。所以我假设我在手动编译器调用中缺少一些东西。



我尝试了一些变体,例如 -std = c ++ 0x -std = gnu ++ 11 无效。

解决方案

我想出来了。不幸的是,我在我的问题上种了一个假标志:它在XCode中没有工作,我有一个不同版本的源文件导入。



问题是, C ++ 11定义了对应于指定的 atomic 的命名类型 atomic_bool ,但 clang不支持



将类型从 atomic_bool 重命名为原子< bool> / p>

I'm trying to compile C++11 code that declares a variable of type std::atomic_bool. This is on Mac OS 10.8.2 with clang:

clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix

clang complains about std::atomic_bool:

clang++ -c -stdlib=libc++ -msse4 -std=c++11 -Wno-unused-parameter -I. -o query.o query.cpp
In file included from query.cpp:1:
[...]
./threadutils.h:33:10: error: no type named 'atomic_bool' in namespace 'std'; did you mean 'atomic_long'?
    std::atomic_bool work;

However, the same file compiles fine in an XCode project using the same compiler. So I assume I'm missing something in my manual compiler invocation.

I tried a few variations such as -std=c++0x and -std=gnu++11, to no avail.

解决方案

I figured it out. Unfortunately I planted a false flag into my question: it didn't work in XCode either, I had a different version of the source file imported there.

The problem was that C++11 defines "a named type atomic_bool corresponding to the specified atomic<bool>", but clang doesn't support that.

Renaming the type from atomic_bool to atomic<bool> fixed it.

这篇关于clang不知道std :: atomic_bool,但XCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆