Reputation: 2641
EDIT: It turns out this really isn't specific to Eclipse Kepler. I had to use the same process for Eclipse Juno. The problem was that there seem to be missing steps in other posts answering this same question.
I'm using Eclipse Kepler for C++ and I'm trying to use C++11 and getting errors. When I compile I get the error
error: range-based-for loops are not allowed in C++98 mode
I've followed the instructions from the post
Eclipse CDT C++11/C++0x support
and the solution given for Eclipse Juno isn't working.
Different comments have suggested restarting eclipse and cleaning and rebuilding. That hasn't made a difference.
Upvotes: 85
Views: 88413
Reputation: 61
I use Eclipse Kepler and to fix it i did this:
1 - Right-Click the Project >> Proprietes >> C/C++ Build :: Settings
2 - Went to GCC G++ Compiler >> Miscellaneous >> Other Flags
I then added -std=c++11
, hit apply and ok
That fixed my problem!
I hope this helps!
Upvotes: 6
Reputation: 115
I'm using Eclipse Luna and there is no "Tool Settings" under C/C++ Build -> Settings. I DID add -std=c++11 to the compiler specs command line under "C/C++ General -> Preprocessor Includes -> Providers" as suggested. But that still did not satisfy my indexer's ability to resolve emplace().
So I looked in the header file for and found that the emplace functions are dependent on __cplusplus >= 201103L. So I just added the preprocessor symbol "__cplusplus" and gave it the value 201103.
Kinda hackish but the indexer is happy. (And makefiles define my build flags, not the eclipse project)
Upvotes: 1
Reputation: 211
Adding dialect flag "-std=c++11" to Project properties-> C/C++ Build -> Settings -> Tool settings (GCC C++ Compiler -> Dialect) solved my problem in Eclipse Kepler, apart from the settings stated above.
Upvotes: 2
Reputation: 8242
There's two things you have to do, first you need to setup your compiler, then you need to setup CDT's language processor. Since you didn't mention which compiler you're using, I'll assume it's GCC but the steps will be similar for other compilers. (Note that you need a compiler that supports C++11, of course.)
Setting up the compiler is fairly straightforward:
At this point you should be able to rebuild your project and get it to run. But CDT still may show errors for C++11 includes. Here's how you can resolve that:
Upvotes: 182
Reputation: 89
Running eclipse indigo and cdt 8.0.2 here. I followed all the guides, but it was still necessary to set the preprocessor define by hand to find things like std::unique_ptr. The include file "memory" checks this. Set __cplusplus to 201103L on the "Symbols" tab under "Paths and Symbols" in "C++ General" in project properties.
Upvotes: 4
Reputation: 25426
As of CDT 8.3 (available as a Kepler update), there is a new dialect option in build settings:
http://wiki.eclipse.org/CDT/User/NewIn83#Build
Upvotes: 13
Reputation: 1108
C++11 support in Eclipse Kepler Service Release 1 (Build id: 20130919-0819)
In the latest release Eclipse Kepler SR1 you only have to add -std=c++11
The "Command to get compiler specs:"-line should look like:
${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11
Upvotes: 25