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

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

    Eclipse C/C++ does not recognize the symbol std::unique_ptr even though you have included the C++11 memory header in your file.

    Assuming you are using the GNU C++ compiler, this is what I did to fix:

    Project -> Properties -> C/C++ General -> Preprocessor Include Paths -> GNU C++ -> CDT User Setting Entries

    1. Click on the "Add..." button

    2. Select "Preprocessor Macro" from the dropdown menu

      Name: __cplusplus     Value:  201103L
      
    3. Hit Apply, and then OK to go back to your project

    4. Then rebuild you C++ index: Projects -> C/C++ Index -> Rebuild

提交回复
热议问题