c++ - 为什么 Eclipse 认为 clang 不支持 std::atomic

标签 c++ eclipse c++11 clang eclipse-cdt

我有一个使用一些 c++11 特性的 eclipse c++ 项目。它使用 cmake 进行构建,因此它在 Eclipse 中设置为具有现有 makefile 的项目。

无论是在 eclipse 中还是从命令行中,它都可以很好地构建 makefile。但是我得到 atomic_bool 的语法错误说符号无法解析。我添加了 -std=c++11在“C/C++ General -> Preprocessor Include Pattern -> Providers -> CDT GCC Built-in Compiler Settings”下,我将 eclipse 中的工具链设置为 MacOSX GCC。

注意:其他 c++11 东西,如 threadshared_ptr不要给出任何语法错误。

错误来自 <atomic>有预处理器的标题 if声明

#if !__has_feature(cxx_atomic)
#error <atomic> is not implemented
#else
...

#else 下面的所有内容都是灰色的。显然__has_feature(cxx_atomic)根据 eclipse 评估为 0。但是,如果我从命令行检查它,它会显示它的计算结果应该为真。

$ echo '__has_feature(cxx_atomic)' | g++ -x c++ -std=c++11 -E -
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 188 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
1

为什么 __has_feature(cxx_atomic)在 Eclipse 中评估为 false 但如果我检查编译器本身则不是?

最佳答案

尝试启用“构建输出解析器”。 http://www.eclipse.org/forums/index.php/t/501479/

关于c++ - 为什么 Eclipse 认为 clang 不支持 std::atomic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22673946/

相关文章:

C++:在类构造函数中初始化chars数组和int

c++ - 如何使用 WaitForSingleObject

C++ iStream、If-Else 和 vector

java - 将 Java 项目从 GitHub 导入到 Eclipse

eclipse - ant4eclipse 异常,同时解决类路径

c++ - 'return *this' 实际上是做什么的?

c++ - 模板内的继承 - 公共(public)成员变得不可见?

c - 在 Windows 中启动失败的二进制文件未找到 Eclipse for C

c++ - 为什么要用 make_unique 调用来初始化 unique_ptr?

c++ - 双重包含和仅 header 库 stbi_image