Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse 3.7.0 Indigo with CDT shows many false compilation errors

Tags:

I have updated my Ubuntu box to 11.10 and then Eclipse also have been updated to 3.7.0 Indigo with CDT 8.0.1

Then the following problem occurs:

Eclipse errors

I have included the vector header file but the compiler said that Symbol 'vector' could not be resolved. I also defined #define int Comparable, but Eclipse also said Symbol 'Comparable' could not be resolved and so on....

Although lots of errors occur, compiling was finished successfully!

I have tried to use g++ to compile the code, it had no problem.

like image 651
zonyitoo Avatar asked Nov 01 '11 05:11

zonyitoo


People also ask

How do I fix errors in Eclipse code analysis?

If it does not help, you can configure Eclipse Code Analyser (which generates the 'errors') in Project->Properties->C/C++ General->Code Analysis. Under the error description you have problem with, try Customize Selected->Scope->Exclusion Patterns.

What causes eclipse to fail to import project files?

This error can be produced by forced closing of eclipse by power failure. Show activity on this post. Deleting the .metadata folder , and then Import project .

How do I fix errors in C++ code analysis?

Updated: You have to add proper paths to Project->Propoerties->C/C++ General->Paths and Symbols. If it does not help, you can configure Eclipse Code Analyser (which generates the 'errors') in Project->Properties->C/C++ General->Code Analysis.

How to get eclipse to consider a symbol to be defined?

Since you can assume the symbol will always be supplied by the compiler, you just tell Eclipse to consider it defined. I had the same problem just recently, where Eclipse complained about undefined macro, that i always supply using -D<MACRO_NAME> compiler option.


2 Answers

The problem is that there are a bunch of include directories that are missing from the indexer's perspective.

Adding the following worked for me, but may depend on your particular setup where they actually exist:

/usr/include/c++/4.6.1
/usr/include/                
/usr/include/c++             
/usr/include/c++/4.6         
/usr/include/x86_64-linux-gnu
/usr/include/asm-generic
/usr/include/c++/4.6.1/x86_64-linux-gnu/

They can be set in Project>Properties>C++ Include Paths

Presumably, in the future, the platform specializations for the CDT will included these automatically. I recall reading that somewhere, but cannot provide a reference.

like image 200
Catskul Avatar answered Sep 23 '22 05:09

Catskul


Time after time a crash of Eclipse, the VM or the computer or even just long months of development start to wear down the stability of the workspace where Eclipse stores everything.

Check the <workspace dir>\.metadata directory to get an idea of just how much Eclipse generates and stores in your workspace. Every time you add a plugin, upgrade a plugin, remove a plugin that puts and changes information in your workspace.

A proof is that this issue usually comes just after upgrading Eclipse. (In my case to Indigo).

The easiest way to fix up a dusty workspace is using the -clean command line argument to the eclipse.exe executable.

Eclipse help docs tell us what this command does:

if set to "true", any cached data used by the OSGi framework and eclipse runtime will be wiped clean. This will clean the caches used to store bundle dependency resolution and eclipse extension registry data. Using this option will force eclipse to reinitialize these caches.

There are three ways one can use the -clean command line argument:

  1. Edit the eclipse.ini file located in your and add it as the first argument on the first line.
  2. Edit the shortcut you use to start Eclipse and add it as the first argument.
  3. Create a batch or shell script that calls the Eclipse executable with the -clean argument.

The advantage of step 3 is you can keep the script around and use it each time you want to clean out the workspace.

This page solved the problem to me!Hope it can help everybody else.

like image 34
Matteo Avatar answered Sep 22 '22 05:09

Matteo