Eclipse 4.6 support c++11
1 配置MinGW-w64环境
使用MinGW时(其中g++ version 4.9.2 ),发现std::to_string()函数无法使用,还是推荐使用snprintf()
。
如果在Windows下搭建MinGW环境,推荐使用MinGw-w64,std::to_string()等函数都能正常使用(其中g++ version 6.3.0),所以后续推荐使用64位版本的MingW,可在nuwen下载MinGW-w64,即mingw-14.1-without-git.exe。
然后双击exe,即可解压到D:\Portable\,配置系统环境变量MINGW_HOME。
MINGW_HOME
最后在Path后追加
;%MINGW_HOME%\bin
,完成配置。
2 支持C++ 11
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
-std=c++11
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++11" 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."