How to enable C++11/C++0x support in Eclipse CDT?
I found this article in the Eclipse forum, just followed those steps and it works for me. I am using Eclipse Indigo 20110615-0604 on Windows with a Cygwin setup.
- Make a new C++ project
- Default options for everything
- Once created, right-click the project and go to "Properties"
- C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags. Put
-std=c++0x
(or for newer compiler version-std=c++11
at the end . ... instead of GCC C++ Compiler I have also Cygwin compiler - C/C++ General -> Paths and Symbols -> Symbols -> GNU C++. Click "Add..." and paste
__GXX_EXPERIMENTAL_CXX0X__
(ensure to append and prepend two underscores) into "Name" and leave "Value" blank. - Hit Apply, do whatever it asks you to do, then hit OK.
There is a description of this in the Eclipse FAQ now as well: Eclipse FAQ/C++11 Features.
Eclipse setting
How do you enable C++11 syntax in Eclipse Neon?
- Right click on your project and click Properties
- Navigate to C/C++ General and Preprocessor Include Paths, Macros etc.
- Select the Providers tab, click on compiler settings row for the compiler you use.
- Add -std=c++11 to Command to get compiler specs.
- Apply changes.
Will look something like this:
${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11
How to enable C++11 in Eclipse Juno/Kepler/Luna CDT?
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:
- Right click your project and click Properties
- Under C/C++ Build click Settings
- Under GCC C++ Compiler, click Miscellaneous
- In the Other Flags box, append "-std=c++11" to the list of tokens.
- Click Apply and OK
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:
- Right click your project and click Properties
- Under C/C++ General click "Preprocessor Include Paths, Macros"
- Select the Providers tab
- There should be an item in the list that says something like "GCC Built in Compiler Settings". Select this entry.
- Uncheck the "Use global provider..." option
- Under the list there's an box that says "Command to get compiler specs." Append "-std=c++0x" to this.
- Move the "GCC Built in Compiler Settings" provider at the top of the list using the 'Move Up' button on the right.
- Click Apply and then OK.
- Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."
How to enable c++11 in eclipse Luna?
For Eclipse Luna, go to Project > Properties > C/C++ Build > Settings > Tools Settings > Cross G++ Compiler (or whichever compiler setting you're using) and choose "ISO C++1y (-std=c++1y)" or "ISO C++11 (-std=c++0x)". Or instead, in "Other dialect flags", you can put std=c++11, or std=c++14, but if you do it this way you'll probably have to take an additional step not covered here so the Eclipse editor will produce error flagging for the correct C++ version in the editor.
How do I use C++0x on Eclipse Helios?
I don´t think you´ll get C++11 with G++ 4.2.1, because the implementation started with 4.3 ...
the current versions are 4.9.x, get newer software.
Related Topics
Method That Converts Uint8_T to String
How Approximation Search Works
Why Should the Implementation and the Declaration of a Template Class Be in the Same Header File
Difference Between the Dot (.) Operator and -≫ in C++
Function With Same Name But Different Signature in Derived Class
Std::Enable_If to Conditionally Compile a Member Function
How to Get Assembler Output from C/C++ Source in Gcc
Calling C++ Member Functions Via a Function Pointer
Why Can't I Make a Vector of References
What Will Happen When I Call a Member Function on a Null Object Pointer
What Is a "Cache-Friendly" Code
Virtual/Pure Virtual Explained
Why Can't C++ Be Parsed With a Lr(1) Parser
Why Doesn't Polymorphism Work Without Pointers/References
Why Use Static_Cast≪Int≫(X) Instead of (Int)X