Disable Eclipse's Error Discovery. (Codan False Positives)

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

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 from 2012, now outdated:


These bogus errors come from Codan. I also issued a bug report (C++03!!!) but the same problem shows up in the latest stable Eclipse so I don't think much has happened :(

Workaround:

Click on the project properties, then C/C++ General > Code Analysis > Syntax and Semantic Errors and deselect whatever false errors you are getting.

I just want to see solely real compiler errors

Of course, you can disable there the static analysis completely, in that case you can accomplish exactly what you want.


UPDATE: 2 users have reported that what Jeevaka wrote helped them. I have tried what he wrote, it did not help me with Juno SR1 and CDT 8.1.1. Perhaps Codan developers have improved static analysis in Juno SR2 and CDT 8.1.2

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

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.

c++11 code generates semantic errors in Eclipse, can't change build settings

First, make sure that your project compiles correctly.

After that, go to C/C++ Build->Tool Chain Editor and choose Current toolchain: Linux GCC (you may need to switch off Display compatible toolchains only). Make sure that the Current builder is still Android Builder.

Now you have full access to C/C++ General->Paths and Symbols page, with h Includes and # Symbols tabs.

On these two tabs, I add manually

C:/Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/include
C:/Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
C:/Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/include/backward

and

__GXX_EXPERIMENTAL_CXX0X__ = 1

Maybe you need to switch to C/C++ Perspective, right-click on the project and launch Index->Rebuild.

Eclipse CDT Plugin keeps giving inexistent errors

Simply rebuild the CDT index. This will remove any wrongly reported errors.

C++11 full support on Eclipse

Eclipse works with C+11 support (Indexer and such) just fine: both Juno and Kepler. The thing is that you have to let Eclipse know that you are going to compile with C++11 support. This is done by providing additional flag -std=c++11 to CDT GCC Builtin Compiler Settings in C/C++ -> Build -> Settings -> Discovery [tab] so it will read something like:

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

And that is all you have to do with Kepler/Juno to get C++11 code highlighted correctly.

Note, this is workspace-wide setting. You can do the same on per project basis if you don't want to set it in workspace.

Eclipse: function 'to_string' could not be resolved

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:

It seems like you have run into the common problem with Codan, see my answer here.


It isn't 100% clear how the code compiles. Within Eclipse? Or from command line, properly setting the flags? So just in case:

You are using a C++11 function. Do you pass the -std=c++0x or the -std=c++11 flags to the compiler (assuming gcc)?

You might have to also add __GXX_EXPERIMENTAL_CXX0X__ to your defines (again, assuming gcc) and restart Eclipse.

Why can't Codan find size_t

Check your indexer settings under Preferences -> C/C++ -> Indexer.

There is a field there called "Filed to index up-front". Its contents should be:

cstdarg, stdarg.h, stddef.h, sys/resource.h, ctime, sys/types.h, signal.h, cstdio

If there is something else in there, try replacing it with the above, then rebuild the index, and see if that fixes the problem.

(In particular, if what you have in that field is stdarg.h, stddef.h, sys/types.h, then I have a pretty good guess as to what went wrong. Back in Eclipse Ganymede, the value of this field was stdarg.h, stddef.h, sys/types.h. In newer versions (Galileo and Indigo), it was changed to the above. However, since this field is part of "preferences", if you exported your Ganymede preferences and imported them into Galileo/Indigo, this field was overwritten with the old Ganymede value. I was burned by this a while ago.)

eclipse cdt can't parse stdint.h

First, to avoid #include_next, we should tell eclipse that __STDC_HOSTED__ is 0. In Project > Properties > C/C++ General > Path and Symbols, add __STDC_HOSTED__ as 0.

Second, you can see some codes like the following in stdint-gcc.h.

#ifdef __INT8_TYPE__
typedef __INT8_TYPE__ int8_t;
#endif

__INT8_TYPE__ things are predefined macros of gcc. We must tell eclipse about them as well. So, add all macros from gcc -E -dM - < /dev/null except __STDC_HOSTED__ which we added before.



Related Topics



Leave a reply



Submit