8

I have got access to a C project at work that I have to implement some stuff in. I was able to load it into eclipse and can Project -> Build All it. Compilation shows no errors or warnings. But in eclipse, there are a lot of errors shown. One example:


There is an enum

typedef enum MeasurementType {
    PN, BB, AM, RES
} MEAS_TYPE;
MEAS_TYPE type;

in one of the files. It is used somewhere else and produces an error like this: enter image description here

It is most interesting, that only AM seems to be a problem, not PN or BB.


I haven't found a satisfying solution to this. I already tried to include all possible directories I could think of in Project Properties -> C/C++ General -> Paths and Symbols (like this post suggests), but that didn't help.

The project itself is compiled with Makefiles (which is why I need Project -> Build All). Can it be that eclipse does not interpret those Makefiles correctly or something? I am a bit lost after messing around with that stuff for a few hours and not getting a single step forward.

EDIT: Here are some screenshots for my build-relevant project properties (at least I believe they are relevent :D). Tell me if you need more information.

enter image description here enter image description here

Community
  • 1
  • 1
brimborium
  • 9,362
  • 9
  • 48
  • 76
  • 2
    You might like to let Eclipse rebuild its index. – alk Nov 07 '12 at 11:49
  • @alk Already did that (was the last point in the suggestion of the SO answer I linked). Didn't help... – brimborium Nov 07 '12 at 11:53
  • 2
    What kind of Eclipse project is this? Did you provide the makefile? It looks as if Eclipse (**not** gcc) is setup to parse the wrong or some additonally, propably outdated includes. – alk Nov 07 '12 at 11:59
  • @alk I added some screenshots. The Makefile is in the root directory of the project. It is a normal C/C++ project (or do you mean something else with that question?). – brimborium Nov 07 '12 at 12:11
  • @alk Hm, you mean in `Project Properties -> C/C++ General -> Paths and Symbols -> Includes`? – brimborium Nov 07 '12 at 12:13
  • 1
    Most propably yes at least if `MeasurementType` comes from your sources. Or is it declared by any library having it's headers installed under `/usr/incldue' or any other system include path? – alk Nov 07 '12 at 12:52
  • @alk I just found out that when I click on `AM` and switch to the declaration (`F3`), I get to choose between the correct one and a variable that is defined somewhere else. I just renamed the enum constant and there we go. All the other errors were solvable by the same procedure. I guess I am not used to this non-OOP stuff... ;) If you put your suggestions in an answer, I can accept and upvote it. Thanks for your help! – brimborium Nov 07 '12 at 13:33

4 Answers4

2

Since I got a suggestion from moooeeeep, I will post the solution here. I am still accepting alk's answer, because he was the one that showed me towards the right direction.

My solution:

If I click on AM in eclipse (the one that is underlined with red) and press F3 to go to the declaration, it actually asked me to which declaration I want to go. It listed the (correct) enum constant as well as some variable from somewhere else. Therefore the problem was that multiple declarations of AM were present in different code locations.

I fixed this problem by just renaming the enum constant to something else (AN in my case). There is no variable with the same name in the code and therefore eclipse was able to refactor it correctly.

brimborium
  • 9,362
  • 9
  • 48
  • 76
2

This is quite an old question, but I hope this short answer can be useful to someone.

I was having similar errors with enums in the IDE but not when compiling, which seemed to indicate a bug in Eclipse's Codan. After upgrading to the new version of Eclipse (Neon 4.6) released in June, the errors have disappeared. Just try updating Eclipse!

Pyves
  • 6,333
  • 7
  • 41
  • 59
  • 1
    Thanks for the answer. I ended up switching to a different IDE for that project. But I will try with Eclipse Neon again. I would much rather work with Eclipse. :) – brimborium Jul 04 '16 at 08:11
1

It looks as if Eclipse (not gcc) is setup to parse the wrong or some additonally, propably outdated (include) source files.

alk
  • 69,737
  • 10
  • 105
  • 255
1

There is a bug report added in Eclipse CDT Bugzilla with regard to this problem: https://bugs.eclipse.org/bugs/show_bug.cgi?id=439553

Compfy
  • 21
  • 1