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?