4

I have locally forked (via hg clone) a C/C++ (Eclipse CDT) project and imported it into my Eclipse workspace. My editor window for the forked project now looks like this:

enter image description here

Clearly, these are not real errors, since the code builds correctly. Also, these errors are not marked in the original project from which this one was forked.

Why does Eclipse think there are errors in this source?

EDIT: Eclipse error messages when hovering over the "bugs" are, e.g., Type int64_t could not be resolved and symbol 'cout' could not be resolved.

EDIT: I've noticed that Eclipse usually shows a "folder" named includes in the project. It is missing for this project. How can I get it back?

enter image description here

1
  • 2
    Looks like Eclipse has a problem with C++ library headers.
    – zch
    Nov 24, 2012 at 17:58

5 Answers 5

3
+50

Eclipse has to know the paths where to find the include files. This may be set using general eclipse settings or project by project.

For some reason it seems like the default paths are not set for your current project.

What you can do: Open the project settings and go to C/C++ General -> Paths and Symbols (at least that is how it is called in my eclipse version) and fix the include directories.

Maybe it is enough to load the default configuration for that specific project. Maybe you have to set up your include pathes by yourself. On Unix / OS X this should usually be usr/include. On Windows I have no idea, but that should be easy to find out.

Afterwards it may be necessary that your rebuild your eclipse index (right click on your project, then index -> rebuild).

If that does not help please share a screenshot of the Paths and Symbols dialog of your project.

Also see the eclipse documentation on this topic.

3
  • To fix the "errors" and get back an "include" folder, I had to manually enter paths like /usr/include under C/C++ General -> Paths and Symbols-> Includes-> GNU C++, then rebuild the index. Note, however, that my working projects do not have any entries in this tab, so I guess this is a workaround for some error that Eclipse has caused when I forked the project.
    – clstaudt
    Nov 25, 2012 at 10:21
  • 1
    It is possible that your other projects do inherit the global settings, while this project was set up to use the project specific configuration. Apart from that... glad it works again ;)
    – Thilo
    Nov 25, 2012 at 10:30
  • It was simply cloned with mercurial and then imported as an existing project into the workspace. One would expect that all settings are identical to the original project.
    – clstaudt
    Nov 25, 2012 at 10:34
2

I had to include

  • CDT Cross GCC Built-in Compiler Settings
  • CDT GCC Built in Compiler Settings [ Shared ]

in Properties for the project -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Providers

0

add this define in Eclipse to Project Properties->C/C++ General->Paths and Symbols

__STDC_FORMAT_MACROS

Rebuild your eclipse index. It will work.

0

This worked on Mac OS X Yosemite 10.10.5, Eclipse version Mars.1 Release (4.5.1):

Since the includes are usually discovered by Eclipse through the toolchain, check that you have an actual toolchain set (when I ran into this problem after importing a project, the toolchain was set to "No toolchain."):

Project -> Properties -> C/C++ Build -> Tool Chain Editor -> Current toolchain

If no toolchains appear in the dropdown, try unchecking "Display compatible toolchains only" and choosing a toolchain (I chose Cross GCC). When I saved the changes and re-opened the project properties to look at this field again, "Display compatible toolchains only" was automatically re-checked.

Then re-index the project:

Project -> C/C++ Index -> Rebuild

This solved the problem for me (the "pseudo-errors" disappeared, and the includes "folder" appeared under my project in the file system view).

-1

Have you #included the correct files in your code? For std::cout it would be:

#include <iostream>

and for int64_t:

#include stdint.h
2
  • Keep in mind that the code compiles correctly, so this is not an error in my code, but strange behavior of Eclipse.
    – clstaudt
    Nov 24, 2012 at 20:51
  • 2
    @cls My C++ is very basic, but perhaps the compiler is including the correct files via some mechanism which Eclipse does not understand. Nov 24, 2012 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.