Enable C++11 in Eclipse Cdt (Juno/Kepler/Luna) Indexer

Enable C++11 in Eclipse CDT (Juno/Kepler/Luna) indexer

Note that this question (and answer) only deals with the Eclipse indexer which is used to highlight errors before compilation takes place. The C++ compiler settings are not changed! (Thus, compilation could still fail because of missing C++11 settings, but have a look at the "Related" section)

To change the Eclipse indexer settings go to
Project properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> tab Providers -> CDT GCC Built-in Compiler Settings

and append -std=c++0x (or -std=c++11) to Command to get compiler specs:

Afterwards it should look something like:

${COMMAND} -E -P -v -dD ${INPUTS} -std=c++0x

Screenshot of the configuration pane with the change applied

Sources

  • http://wiki.eclipse.org/CDT/User/FAQ#CDT_does_not_recognize_C.2B.2B11_features
  • http://www.eclipse.org/forums/index.php/mv/msg/373462/909018/#msg_909018

Related

  • Eclipse CDT C++11/C++0x support
  • https://stackoverflow.com/a/17499266/760746 (C++11-enable the compiler (Kepler and before))
  • https://stackoverflow.com/a/22480299/760746 (C++11-enable the compiler (Kepler (updated) and newer)

Update

Successfully tested with Eclipse

  • Kepler (CDT 8.2)
  • Luna (CDT 8.4)

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:

  1. Right click your project and click Properties
  2. Under C/C++ Build click Settings
  3. Under GCC C++ Compiler, click Miscellaneous
  4. In the Other Flags box, append "-std=c++11" to the list of tokens.
  5. 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:

  1. Right click your project and click Properties
  2. Under C/C++ General click "Preprocessor Include Paths, Macros"
  3. Select the Providers tab
  4. There should be an item in the list that says something like "GCC Built in Compiler Settings". Select this entry.
  5. Uncheck the "Use global provider..." option
  6. Under the list there's an box that says "Command to get compiler specs." Append "-std=c++0x" to this.
  7. Move the "GCC Built in Compiler Settings" provider at the top of the list using the 'Move Up' button on the right.
  8. Click Apply and then OK.
  9. Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."

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

Eclipse image setting

Eclipse CDT enabling c++ 11 problems

After a lot of research, I solved this issue by downgrading the CDT plugin (was 8.1.2, d/g to 8.0.2).
Apperantly there were some compatibility issues.



Related Topics



Leave a reply



Submit