Eclipse CDT “Symbol NULL could not be resolved”

后端 未结 13 1813
北荒
北荒 2020-12-06 04:32

I just installed Eclipse CDT with MinGW. All the environment variables are set, includes, etc. Tried running a hello world and everyth

相关标签:
13条回答
  • 2020-12-06 04:46

    Set ${COMMAND} to gcc on Linux

    Under "Preprocessor Include Paths, Macros, etc." and "CDT GCC Built-in Compiler Settings" there is an undefined ${COMMAND} variable if you imported the sources from an existing Makefile project.

    Eclipse tries to run that command to parse its stdout to find headers, but ${COMMAND} is not set by default, and so it is not able to do so.

    I have explained this in more detail at: "Unresolved inclusion" error with Eclipse CDT for C standard library headers

    0 讨论(0)
  • 2020-12-06 04:47

    I was having the same error and I fixed it by right clicking on your project, hover over the index tab and click Rebuild. My errors went away after that.

    0 讨论(0)
  • 2020-12-06 04:52

    I was looking for answers here about this because I found out that CDT sometimes fails resolving the headers of the standard library. I still don't know why and how to reproduce the bug. Just restart CDT and all is solved.

    0 讨论(0)
  • 2020-12-06 04:56

    I had the same problem: my makefile was running fine but I was getting errors like yours from the Eclipse CDT view.

    I closed the current project, I opened a new "Makefile project with existing code" , specifying the right location source location of my project. After this, I checked that: right click project / C++ general / Paths and symbols / Gnu C++ / include directories is not empty and includes the correct paths of my project.

    Then, I rebuilt the index (right click / index / rebuild).

    Also, I use Eclipse CDT 7 and not Eclipse CDT 8 because CDT8 sometimes gives me compile errors from the GUI that I could not solve, eventhough the makefile was fine.

    0 讨论(0)
  • 2020-12-06 04:57

    As Bob mentioned, i fix the bug just by rebuilt the index

    1. right your project
    2. choose "Index"
    3. choose "Rebuild"
    0 讨论(0)
  • 2020-12-06 04:57
    • reason is :

    NULL defined in stddef.h, but stddef.h is in xxx/include/linux not xxx/include

    -> even though you have added MingW's xxx/include, still can not found NULL

    • the solution is:

    add your MingW's include/linux path to your project

    • referer

    (1) example of my xscale crosscompiler's include/linux path is: /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/sysroot/usr/include/linux

    added GNU C++ include linux path

    (2) my post:Ubuntu Eclipse: Symbol ‘NULL’ could not be resolved

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