Turn off eclipse errors (that aren't really errors)

soandos picture soandos · Jan 3, 2013 · Viewed 22.1k times · Source

Possible Duplicate:
Disable Eclipse's error discovery. (Codan false positives)

With GCC 4.8/Clang 3.3 C++ support so far ahead of what Eclipse is doing with syntax checking (in terms of feature support), Eclipse is marking many things as errors that are actually valid code (template aliasing happens to be my main problem, but there are other issues as well).

When I compile (or attempt to anyway, having some issues, see here for more) whatever compiler happens to be doing the work does its job, and its errors get propagated through, but the code that it says is OK is still underlines (red and gold spiders for errors and warnings respectively), which makes it much harder to see what is going on.

Is there a way to get rid of these errors/warnings?

Even better would be a way to get rid of warnings only after compile attempt, and for as long as the relevant parts of the code don't change, but still leave them enabled in general.

(Actually the best would be a plugin for Eclipse that supports all, or at least more of C++11 than Juno does by itself, but I can't seem to find that)

Answer

Ali picture Ali · Jan 3, 2013

UPDATE: It's been a long time since I posted the original answer and it has become outdated. I double-checked today (Mar 15, 2014): in Eclipse Kepler (Build id 20130614-0229) it is sufficient to

  • add under Project > Properties > C/C++ Build > Settings then on the Tool Settings tab GCC C++ Compiler > Miscellaneous the -std=c++11 flag,

  • then under Window > Preferences > C/C++ > Build > Settings on the Discovery tab chose CDT GCC Built-in Compiler Settings and add the -std=c++11 flag to Command to get compiler specs. On my machine it looks like this after the change:

    ${COMMAND} -E -P -v -dD -std=c++11 "${INPUTS}"

  • clean and rebuild both your project and your index (Project > C/C++ Index > Rebuild) as Eclipse tends to cache error messages and show them even though they are gone after changing the settings.

This works on my machine for sure. If it doesn't on yours, then you might want to give a shot to this: C++11 full support on Eclipse although I am neither sure about the correctness of this approach nor was it necessary to do it on my machine. As of March 7, 2014 users claim that it helped them whereas the above approach didn't.


The original post, now outdated:

These bogus errors come from Codan. The whole thing is because Codan and the compiler have different understanding of C++ and Codan is buggy.

Possible workarounds

  1. Click on the project properties, then C/C++ General > Code Analysis > Syntax and Semantic Errors and deselect whatever false errors you are getting. Drawback: you will most likely end up disabling most of the errors and warning one by one, which is quite annoying.

  2. Disable the static analysis completely at C/C++ General > Code Analysis > Syntax and Semantic Errors. You won't get the true errors from Codan but only later from the compiler.

None of them is a solution but at least you can still use the Eclipse IDE.