How to enable C++11/C++0x support in Eclipse CDT?

后端 未结 17 1750
说谎
说谎 2020-11-22 00:13

Eclipse 3.7.1 CDT 1.4.1 GCC 4.6.2

This is an example of a piece of C++11 code:

auto text = std::unique_ptr(new char[len]);
17条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 00:32

    For the latest (Juno) eclipse cdt the following worked for me, no need to declare __GXX_EXPERIMENTAL_CXX0X__ on myself. This works for the the CDT indexer and as parameter for the compiler:

    "your project name" -> right click -> properties:

    C/C++ General -> Preprocessor Include Paths, Macros etc. -> switch to the tab named "Providers":

    • for "Configuration" select "Release" (and afterwards "debug")

    • switch off all providers and just select "CDT GCC Built-in Compiler Settings"

    • uncheck "Share setting entries between projects (global provider)"

    • in the "Command to get compiler specs:" add "-std=c++11" without the quotes (may work with quotes too)

    • hit apply and close the options

    • rebuild the index

    Now all the c++11 related stuff should be resolved correctly by the indexer.

    win7 x64, latest official eclipse with cdt mingw-w64 gcc 4.7.2 from the mingwbuilds project on sourceforge

提交回复
热议问题