Eclipse CDT shows semantic errors, but compilation is ok

后端 未结 20 1390
青春惊慌失措
青春惊慌失措 2020-12-01 07:42

I have installed Eclipse Indigo for C/C++ Linux developers on Ubuntu 10.04 x86.

When I use common predefined macro __BASE_FILE__ Eclipse says Sym

相关标签:
20条回答
  • 2020-12-01 08:00

    The simplest solution is to reset the indexer:

    Window / Preferences / C/C++ / Indexer.
    uncheck "Enable indexer" ->>OK
    rebuild all, may show lots of errors
    check "Enable indexer" ->>OK
    rebuild all

    This error can be produced by forced closing of eclipse by power failure.

    0 讨论(0)
  • 2020-12-01 08:00

    adding as another answer, hopefully this will help someone.

    I have a ~simple workspace (1 c++ shared-object (linux's version of a DLL, 3 c++ executables, and a pydev python project)

    I checked out all the code to a new machine, and it builds fine but had numerous 'semantic errors' on std-c and std-C++ code and includes.. I went through all the discovery / indexer setting to no avail.

    ==> deleting the entire .metadata folder fixed this.

    Since i had nothing non-trivial set up in the workspace (all in the project files / makefiles), eclipse happily created a fresh workspace, and i simply had to do a file->import-> existing projects

    0 讨论(0)
  • 2020-12-01 08:02

    Deleting the .metadata folder , and then Import project .

    This way is OK!

    0 讨论(0)
  • 2020-12-01 08:02

    IMO the correct solution is to define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols -> Symbols tab. 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.

    0 讨论(0)
  • 2020-12-01 08:02

    I have the same problem. Compiler preprocesses ok, but static analyzer doesn't. In my source file:

    #define PLATFORM_INC_FILES
    #include <platform.h>
    
    int coflags=O_BINARY; // Undefined symbol
    

    In platform.h (an OS dependent header to help creating portable code):

    #ifdef PLATFORM_INC_FILES
        #include <stdio.h>
        ...
    

    It looks like static analyzer doesn't take the .c #define statements into account when preprocessing included headers. By defining it at the symbols dialog, errors dissapear, but that is a project scope symbol definition, resulting in every source to include every system header in my case.

    Hope it gets fixed soon...

    Using Eclipse Mars and MinGW on MSIS2.

    0 讨论(0)
  • 2020-12-01 08:05

    Window -> Preferences -> C/C++ -> Code Analysis -> Syntax and Semantic Errors: OFF

    This won't solve the cause of the problem but at least will stop the false errors from being shown.

    0 讨论(0)
提交回复
热议问题