1 配置MinGW-w64環(huán)境
使用MinGW時(其中g++ version 4.9.2 )主经,發(fā)現(xiàn)std::to_string()函數(shù)無法使用糠睡,還是推薦使用snprintf()
止潘。
如果在Windows下搭建MinGW環(huán)境瓦宜,推薦使用MinGw-w64筐喳,std::to_string()等函數(shù)都能正常使用(其中g++ version 6.3.0)姑原,所以后續(xù)推薦使用64位版本的MingW悬而,可在nuwen下載MinGW-w64,即mingw-14.1-without-git.exe。
然后雙擊exe锭汛,即可解壓到D:\Portable\笨奠,配置系統(tǒng)環(huán)境變量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
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."