简体   繁体   English

名称空间“ std”中没有名为“ atomic”的类型

[英]No type named 'atomic' in namespace 'std'

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)

There are several things that need to be true for your code to work: 要使代码正常工作,需要满足以下几项要求:

  1. You need to #include <atomic> 您需要#include <atomic>

  2. You need to compile the code as C++11 or C++14 ( -std=c++11 or -std=c++14 (or c++0x for older compilers)) 您需要将代码编译为C ++ 11或C ++ 14( -std=c++11-std=c++14 (或对于较旧的编译器为c++0x ))

  3. Your compiler and standard library needs to support enough of C++11 to provide atomic ( http://clang.llvm.org/cxx_status.html ) 你的编译器和标准库需要的C ++ 11的支持足以提供atomichttp://clang.llvm.org/cxx_status.html

在我的Makefile中的CXXFLAGS中添加-std=c++11 >对我有用!

您需要按以下内容将其写入定义的变量。

    std::atomic<std::int> index;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM