Tho*_*ler 4 c++ macos std clang c++11
我正在尝试编译声明类型为std :: atomic_bool的变量的C++ 11代码.这是在Mac OS 10.8.2上使用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
Run Code Online (Sandbox Code Playgroud)
clang抱怨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;
Run Code Online (Sandbox Code Playgroud)
但是,使用相同的编译器在XCode项目中编译相同的文件.所以我假设我在手动编译器调用中遗漏了一些东西.
我尝试了一些变化,如-std=c++0x和-std=gnu++11,无济于事.
小智 5
我发现了同样的问题。就我而言,我通过包含原子来解决它:
#include <atomic>
static std::atomic_bool varname;
Run Code Online (Sandbox Code Playgroud)
之后,我可以在 Linux (Ubuntu) 上使用 std=c++11 调用 g++,并在 XCode 上进行编译。
| 归档时间: |
|
| 查看次数: |
1858 次 |
| 最近记录: |