Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ eclipse wrong error interpretation

Tags:

c++

eclipse

I'm having a problem with eclipse C++. My project compiles and runs but eclipse (juno) keeps saying there are thousands of errors. For example there's a function SetRun in my code, and eclipse mentions this error: "called Invalid arguments 'Candidates are: void SetRun(?)'", whereas SetRun is of type static void SetRun (uint32_t run);

I have quite a lot of similar errors like that, where eclipse doesn't seem to understand the type of the function and puts a '?' instead.

I also have many errors like this: "symbol '*' could not be resolved."

I think this is all part of the same issue.

What can I do to make eclipse stop telling me about these errors?

like image 940
bob Avatar asked Jul 06 '12 00:07

bob


3 Answers

I tried the proposed solution and it did not work for me. What helped was to turn off CodeAnalysis for the project. I went to Properties->C/C++ General->Code analysis. Selected Use Project Settings and turned off all errors. This is of course very annoying and unfortunate and I would be glad to know when it is properly fixed. It is a shame we can't get use of the feature any other decent IDE has.

like image 189
Moshe Kravchik Avatar answered Sep 28 '22 05:09

Moshe Kravchik


In Eclipse:

  • right click the project,
  • click properties
  • Expand "C/C++ general" the item in the left hand tree view by clicking the arror, (just clicking the item itself does not expand the suboptions)
  • From the suboptions select "Preprocessor Include Paths, Macros etc."
  • Click the tab "Providers" and check the box next to "CDT GCC Built-in Compiler Settings [ Shared ]".
like image 23
Catskul Avatar answered Sep 28 '22 05:09

Catskul


I had a lot of these errors whicle to trying to get CODAN to run over some code which was destined for a Mac. My Mac SDK libraries were included via symlinks as in this question (but not all of them - stay tuned!) In the end, it turned out that I didn't have all the headers included. For example, I had the following function call:

IORegistryEntryGetParentEntry(service, kIOServicePlane, &parent);

Which was giving the error:

Invalid arguments 'Candidates are: ? IORegistryEntryGetParentEntry(?,?,?)'

Now, the correct signature of the function, defined in IOKit/IOKitLib.h (which I did have) is:

kern_return_t IORegistryEntryGetParentEntry(
    io_registry_entry_t     entry,
    const io_name_t         plane,
    io_registry_entry_t    *parent );

Now, if we take the first argument and trace the type definitions, we get:

typedef io_object_t         io_registry_entry_t; (in IOKit/IOTypes.h)
typedef mach_port_t         io_object_t; (in IOKit/IOTypes.h)
typedef mach_port_name_t    mach_port_t; (in mach/port.h)
typedef natural_t           mach_port_name_t; (in mach/port.h)

And then! I didn't have the include which defined __darwin_natural_t. This include was actually in i386, which I didn't have in my symlink directory. Adding it completed the chain:

typedef __darwin_natural_t  natural_t; (in i386/vm_types.h)
typedef unsigned int        __darwin_natural_t; (in i386/_types.h)

Finally, CODAN knew what type argument 1 of IORegistryEntryGetParentEntry() was supposed to be, and the error changed to:

Invalid arguments 'Candidates are: kern_return_t IORegistryEntryGetParentEntry(io_registry_entry_t ,?,io_registry_entry_t*)'

I repeated this "type-trace" for the other arguments, and found that the error disappeared (I didn't even need to rebuild the index, but YMMV). Of course, you would need to find the headers that you need and may sure they are included - the above is just an example!

like image 45
Inductiveload Avatar answered Sep 28 '22 07:09

Inductiveload