简体   繁体   English

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

[英]Why does Eclipse think clang doesn't support std::atomic

I have an eclipse c++ project that uses some c++11 features. 我有一个使用某些c ++ 11功能的eclipse c ++项目。 It uses cmake for building so it is setup in eclipse as a project with existing makefiles. 它使用cmake进行构建,因此在eclipse中将其设置为具有现有Makefile的项目。

It builds fine with the makefiles either in eclipse or from the command line. 使用Eclipse或命令行中的makefile可以很好地构建它。 But I get syntax errors with atomic_bool saying the symbol can't be resolved. 但是我收到atomic_bool语法错误,说该符号无法解析。 I have added -std=c++11 under 'C/C++ General -> Preprocessor Include Pattern -> Providers -> CDT GCC Built-in Compiler Settings' and I have the toolchain in eclipse set to MacOSX GCC. 我在“ C / C ++常规->预处理程序包含模式->提供程序-> CDT GCC内置编译器设置”下添加了-std=c++11 ,并且将eclipse中的工具链设置为MacOSX GCC。

Note: other c++11 things like thread or shared_ptr don't give any syntax errors. 注意:其他c ++ 11之类的东西,例如threadshared_ptr不会给出任何语法错误。

The errors come from the <atomic> header where there is the preprocessor if statement 错误来自<atomic>标头,其中有预处理器if语句

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

Everything below the #else is grayed out. #else下的所有内容均为灰色。 So apparently __has_feature(cxx_atomic) evaluates to 0 according to eclipse. 因此,显然__has_feature(cxx_atomic)根据月食评估为0。 But if I check it from the command line it shows that it should evaluate to true. 但是,如果我从命令行检查它,则表明它应该评估为true。

$ 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

Why does __has_feature(cxx_atomic) evaluate to false in Eclipse but not if I check the compiler itself? 为什么__has_feature(cxx_atomic)在Eclipse中评估为false,但如果我检查编译器本身,则不是?

Try a Enabling "Build output parser". 尝试启用“构建输出解析器”。 http://www.eclipse.org/forums/index.php/t/501479/ http://www.eclipse.org/forums/index.php/t/501479/

我也遇到了这个问题,支持其他C ++ 11功能,但不支持atomic。

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

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