📅 2014-Nov-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cpp, eclipse, error ⬩ 📚 Archive
I had some C++ code in Eclipse CDT. It was indicating that some lines of code had error like this:
function to_string could not be resolved Method length could not be resolved
This code compiles correctly without any error or warning. I was just looking for a way to make this spurious error highlighting in Eclipse go away.
These errors are shown by the Indexer in Eclipse. It may not be able to resolve symbols because these symbols are not visible to it. This can happen for example if:
Indexer is using a different version of the compiler
Indexer is using compiler directives that are different
Indexer is not aware of the include directories of libraries you are using.
My above errors went away when I solved them like this:
to_string is a C++11 feature. So, I enabled
-std=c++11 in the Indexer compiler settings as described here.
length was a class method from an external library that I was using. I added the include directory of that library to my Project Properties as described here.
Tried with: Eclipse Luna 4.4.1, GCC 4.9.2 and Ubuntu 14.04