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

后端 未结 17 1544
说谎
说谎 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:30

    When using a cross compiler, I often get advanced custom build systems meticulously crafted by colleagues. I use "Makefile Project with Existing code" so most of the other answers are not applicable.

    At the start of the project, I have to specify that I'm using a cross compiler in the wizard for "Makefile Project with Existing Code". The annoying thing is that in the last 10 or so years, the cross compiler button on that wizard doesn't prompt for where the cross compiler is. So in a step that fixes the C++ problem and the cross compiler problem, I have to go to the providers tab as mentioned by answers like @ravwojdyla above, but the provider I have to select is the cross-compiler provider. Then in the command box I put the full path to the compiler and I add -std=gnu++11 for the C++ standard I want to have support for. This works out as well as can be expected.

    You can do this to an existing project. The only thing you might need to do is rerun the indexer.

    I have never had to add the experimental flag or override __cplusplus's definition. The only thing is, if I have a substantial amount of modern C code, I have nowhere to put the C-specific standard option.

    And for when things are going really poorly, getting a parser log, using that command in the Indexer submenu, can be very informative.

提交回复
热议问题