eclipse3.8之前的__cplusplus的定义是199711L,如果使用c++11标准中的特性,ide中会报各种未找到定义。
需要修改设置如下:
Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Build-in Compiler Settings,
在原有的参数后面加入: -std=c++11
project properties->C/C++ general ->Paths and Symbols ->Sysmbols,添加
name:__GXX_EXPERIMENTAL_CXX0X__
value :__GXX_EXPERIMENTAL_CXX0X__
To fix C++11 syntax highlighting go to:
Project Properties --> C/C++ General --> Paths and Symbols --> Symbols --> GNU C++
and overwrite the symbol (i.e. add new symbol):
__cplusplus
with value
201103L
UPDATED: If you use newer version of Eclispe (as of 2016) and still experience the same problem, try value (as pointed by jose.diego):
201402L
Make sure that indexer is enabled in Project settings (C/C++ general --> Indexer)
Then reindex (Project --> C/C++ Index --> Rebuild)
取消c++11的命名规则:
-D_GLIBCXX_USE_CXX11_ABI=0
eclipse.ini:
-showsplash
org.eclipse.platform
-vmargs
-server
-Xmx1G
-Xms1G
-Xmn256m
-XX:PermSize=64m
-XX:MaxPermSize=128m
-XX:+UseFastAccessorMethods
-XX:+UseG1GC
-XX:MaxGCPauseMillis=10