23

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)

Cœur
  • 37,241
  • 25
  • 195
  • 267
soandos
  • 4,978
  • 13
  • 62
  • 96
  • Try following this link it helped me out awhile back, [Disable Syntax Checking](http://stackoverflow.com/questions/9148417/any-way-to-disable-syntax-checking-for-a-project) – Jonny Henly Jan 03 '13 at 01:49
  • @JonnyHenly but I do want to compile it – soandos Jan 03 '13 at 01:50
  • I don't have much experience with C++11 but is it possible to just edit your classes with Eclipse and then when it comes time to compile use terminal or command prompt to mannually run the compiler. I know that would be trivial but I think that would take care of your problem – Jonny Henly Jan 03 '13 at 01:55
  • 2
    I may as well be using Gedit then. It totally makes eclipse useless – soandos Jan 03 '13 at 02:06
  • @soandos Yes, it's very annoying. I don't understand why they ship the IDE like that. The first thing the user has to do is to google around and figure out how to disable this crappy feature. See my linked answer, it solved the issue for me. – Ali Jan 03 '13 at 08:11

2 Answers2

20

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.

Community
  • 1
  • 1
Ali
  • 56,466
  • 29
  • 168
  • 265
  • Looks good. As an aside, I find it ridiculous that compiler writers have implemented the features before Eclipse can even recognize it. – soandos Jan 03 '13 at 08:23
  • (and good catch on the dupe, my bad) – soandos Jan 03 '13 at 08:24
  • @soandos What I find even more ridiculous is that they produced a separate standalone tool (Codan) to do the compiler's job. I hope the situation will change with clang and finally the static analysis tool (clang instead of Codan) and the compiler (again clang) will have the same understanding of C++. – Ali Jan 03 '13 at 08:26
  • I've been trying to get clang to work, but the linker seems like is missing something. Ideas? http://stackoverflow.com/questions/14118224/clang-linker-issues-from-source-to-gcc-snapshot – soandos Jan 03 '13 at 08:27
  • 2
    @soandos No problem. They shouldn't ship an IDE that is practically useless if you don't disable this buggy feature first. – Ali Jan 03 '13 at 08:28
  • @soandos Unfortunately, I have no idea about the linker, sorry. I have never tried it with Eclipse. I upvoted and favorited your question, and curious what answers you will get. – Ali Jan 03 '13 at 08:29
  • Thanks, its just annoying/strange (it won't work outside eclipse either) – soandos Jan 03 '13 at 08:30
  • @soandos Sorry, I have no idea, I have never tried that way you write in your question. – Ali Jan 03 '13 at 08:31
  • I have a file full of fooStruct foo[] = { { x: 0, y: 1 } }; and it's all red because Codan doesn't understand. But I love being able to navigate with the rest of the tools Eclipse provides, almost as well as, in some cases better than, Visual Studio. So you can go back to gedit if you want :) – cardiff space man Apr 05 '13 at 00:03
  • Turning off all the error checking is not a solution to the problem, just another problem. There's some magical incantation out there that will make this work in Kepler, it's just different from the dozens and dozens of recipes you find in web searches for Juno. So, move along, this is NOT the answer you are looking for. – Wexxor Oct 18 '13 at 19:31
  • 1
    The updated answer also works with the other std options for gcc, for instance I used: `${COMMAND} -E -P -v -dD -std=c++11 "${INPUTS}"`. Also, in another answer I read on Stack Overflow, it mentioned sorting the CDT GCC Built-in Compiler Settings up to the top of the tree. After that, I right clicked the project and did Index-Rebuild, which removed the errors. – Chris Chiasson May 26 '16 at 20:04
  • Worked! Thanks! ^_^ – Anirudh Murali Nov 30 '16 at 11:20
  • It is Oct 2017, and I have this error on two Windows 7 machine, and one Linux machine. Another Win7 with Eclipse 4.7.1 system somehow does not have this error. Efforts are made to try replicating it, but fail. Even copying the entire eclipse folder does not help. I cant believe how they let this error persist. – CaTx Oct 14 '17 at 20:21
9

Go to Window->Preferences write analysis into the search field select C/C++->Code Analysis and there you can turn off everything.

Kocka
  • 1,634
  • 2
  • 13
  • 21