xcode 命名空间“std”中没有名为“atomic”的类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15720392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No type named 'atomic' in namespace 'std'
提问by Hobbyist
Why doesn't
为什么不
std::atomic<int> index;
Work?
工作?
Currently using LLVM 3.1 with these params
当前使用带有这些参数的 LLVM 3.1
C Language Dialect GNU [-std=gnu99]
C++ Language Dialect [-std=c++11]
C++ Standard Library libc++(LLVM C++ standard library with C++11 support)
回答by Jesper Juhl
There are several things that need to be true for your code to work:
有几件事情需要你的代码才能工作:
You need to
#include <atomic>
You need to compile the code as C++11 or C++14 (
-std=c++11
or-std=c++14
(orc++0x
for older compilers))Your compiler and standard library needs to support enough of C++11 to provide
atomic
(http://clang.llvm.org/cxx_status.html)
你需要
#include <atomic>
您需要将代码编译为 C++11 或 C++14(
-std=c++11
或-std=c++14
(或c++0x
对于较旧的编译器))你的编译器和标准库需要支持足够的 C++11 来提供
atomic
(http://clang.llvm.org/cxx_status.html)
回答by tamtam
Adding -std=c++11
to CXXFLAGS in my Makefile -> that works for me!
-std=c++11
在我的 Makefile 中添加到 CXXFLAGS -> 对我有用!
回答by 524888 Wusi
You need to write it as the following to defined variable.
您需要将其编写为以下定义的变量。
std::atomic<std::int> index;