Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

Eclipse CDT indexer does not know C++11 containers

I configured a C++11 project in Eclipse CDT to use gcc-4.7. It is not the default compiler on my system, which does not support C++11. In order for compilation to work, I need to pass the flag -std=c++11 and also include the following header path: /usr/local/Cellar/gcc/4.7.2/gcc/include/c++/4.7.2

Whenever I use C++11 container types like std::unordered_set or std::unordered_map, the CDT indexer complains: Symbol unordered_set could not be resolved. How can I tell the indexer to resolve these symbols correctly?

This is how I have configured my indexer:

enter image description here

As far as I understand the settings, the indexer is supposed to use the compiler settings from the currently active build configuration. Compilation works fine, so why doesn't indexing, too?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Setting up **__GXX_EXPERIMENTAL_CXX0X__** does not help in my case (Jul 2014, Eclipse Kepler 20130919, Ubuntu 12.04).

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)

if the problem still persist reindex once again. It should work now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...