該C++工程可以通過編譯並正確運行,可是在Text Editor上面顯示一些下劃線和bug標誌,非常有礙觀瞻,而且估計會影響智能提示。
啓動eclipse後,經過 Window-->Preferences-->C/C++-->Build-->Environment增加Environment variables:
Name: C_INCLUDE_PATH
Value: /usr/include
Name: CPLUS_INCLUDE_PATH
Value: /usr/include/c++/4.6
對於諸如下面vector,bitset等等c/c++符號不能解析的問題,
symbol bitset could not be resolved
解決辦法類似:
Name: C_INCLUDE_PATH
Value: /usr/include:/usr/include/linux:/usr/include/i386-linux-gnu
Name: CPLUS_INCLUDE_PATH
Value: /usr/include/c++/4.6:/usr/include/c++/4.6/i686-linux-gnu
重啓之後,右鍵點擊該工程,index > Rebuild 就可以了。
如果有在PATH中找不到g++的錯誤,那麼添加下面的環境變量就可以了:
Name: PATH
Value: /usr/bin
這樣還會消除編輯器上標示的其他一些奇怪的錯誤,例如bitset<5>: invalid template argument。
相關知識:
The C/C++ indexer uses the parser to create a database of your source and header files that provides the basis for C/C++ search, navigation features and parts of content assist.