简体   繁体   中英

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

I have an eclipse c++ project that uses some c++11 features. It uses cmake for building so it is setup in eclipse as a project with existing makefiles.

It builds fine with the makefiles either in eclipse or from the command line. But I get syntax errors with atomic_bool saying the symbol can't be resolved. 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.

Note: other c++11 things like thread or shared_ptr don't give any syntax errors.

The errors come from the <atomic> header where there is the preprocessor if statement

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

Everything below the #else is grayed out. So apparently __has_feature(cxx_atomic) evaluates to 0 according to eclipse. But if I check it from the command line it shows that it should evaluate to 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?

Try a Enabling "Build output parser". http://www.eclipse.org/forums/index.php/t/501479/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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