Eclipse 4.6 support c++11

1 配置MinGW-w64環(huán)境

使用MinGW時(shí)(其中g(shù)++ version 4.9.2 ),發(fā)現(xiàn)std::to_string()函數(shù)無(wú)法使用,還是推薦使用snprintf()。
  如果在Windows下搭建MinGW環(huán)境,推薦使用MinGw-w64,std::to_string()等函數(shù)都能正常使用(其中g(shù)++ version 6.3.0),所以后續(xù)推薦使用64位版本的MingW,可在nuwen下載MinGW-w64,即mingw-14.1-without-git.exe。

mingw-14.1-without-git.exe

然后雙擊exe,即可解壓到D:\Portable\,配置系統(tǒng)環(huán)境變量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:

  1. Right click your project and click Properties
  2. Under C/C++ Build click Settings
  3. Under GCC C++ Compiler, click Miscellaneous
  4. In the Other Flags box, append "-std=c++11" to the list of tokens.
  5. 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:

  1. Right click your project and click Properties
  2. Under C/C++ General click "Preprocessor Include Paths, Macros"
  3. Select the Providers tab
  4. There should be an item in the list that says something like "GCC Built in Compiler Settings". Select this entry.
  5. Uncheck the "Use global provider..." option
  6. Under the list there's an box that says "Command to get compiler specs." Append "-std=c++11" to this.
  7. Move the "GCC Built in Compiler Settings" provider at the top of the list using the 'Move Up' button on the right.
  8. Click Apply and then OK.
  9. Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."
-std=c++11
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容