0

When build with Eclipse get warnings and errors about c++0x keywords. Example:

identifier ‘decltype’ will become a keyword in C++0x

How to workaround it?

EDIT:

Project->Properties->C/C++ Build->Discovery options->GCC C++ Compiler->Compiler Invocation Arguments->[-E -P -v -dD ${plugin_state_location}/specs.c --std=gnu++0x]

but it hasnt effect, intresting, even if put there empty string it will try to compile with the same errors. Dont know for what this parameter needed(

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Yola
  • 18,496
  • 11
  • 65
  • 106
  • Are you actually trying to compile with C++11? – Andrew Marshall Dec 19 '11 at 16:51
  • what toolchain are you using gcc? if so you need to pass a flag to enable the c++0x features. -std=c++0x or -std=gnu++0x – ted Dec 19 '11 at 16:52
  • @ted, Current toolchain: Linux GCC. – Yola Dec 19 '11 at 16:59
  • _decltype is a C++0x extension which isn't yet fully supported by GCC. It is an operator which takes an expression and returns a type._ i took this from here http://stackoverflow.com/questions/2763824/decltype-result-of-or-typeof trying to see if it is outdated – ted Dec 19 '11 at 17:27
  • According to this http://gcc.gnu.org/projects/cxx0x.html it should be implemented in gcc >= 4.3 (see _Declared type of an expression_) – ted Dec 19 '11 at 17:39
  • I am wondering about some of the parameters though, i.e. _-E Stop after the preprocessing stage; do not run the compiler proper. The output is preprocessed source code, which is sent to the standard output._ (from man gcc) the question is can you try with onyl one cpp file and compile it directly from a shell? `g++ main.cpp -o main -std=c++0x` should do however i cant try it, to lazy to brin up linux on the universities box. This would determine if the problem originates from exclipse not passing the parameters right. – ted Dec 19 '11 at 17:45
  • I actually tried to launch eclipse on the unis box, but they dont have gcc installed. However the Warnings indicate this `Description Resource Path Location Type Error launching external scanner info generator (g++ -E -P -v -dD C:/***/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp) demo [Discovery Options]`. this hints that you are only changing the flags for the IDE-Autocomplete or something like that, not for the actual compilation. – ted Dec 19 '11 at 17:50

1 Answers1

5

Try this:

Project -> Properties -> C++-Build[Settings] -> G++Compiler[miscellanous] -> Other flags

Add "-std=c++0x" there.

ted
  • 4,791
  • 5
  • 38
  • 84