问题
I just installed Eclipse
CDT
with MinGW
.
All the environment variables are set, includes, etc. Tried running a hello world and everything seems to be fine.
I tried loading a C
project that I had before in my computer, it seems to load everything fine, yet I get the following error with the NULL
symbol :
Symbol 'NULL' could not be resolved
Any insights? Thanks!
回答1:
NULL is usually defined in stddef.h. This file is also usually included with stdlib.h and stdio.h.
And, you could always do this:
#ifndef NULL
#define NULL ((void *) 0)
#endif
回答2:
As Bob mentioned, i fix the bug just by rebuilt the index
- right your project
- choose "Index"
- choose "Rebuild"
回答3:
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.
回答4:
- 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

(2) my post:Ubuntu Eclipse: Symbol ‘NULL’ could not be resolved
回答5:
I just fixed an error like this and thought as no one else had found this solution I'd post it. I found that the stdlib had declared NULL as ___need_NULL in my AVR GCC compiler. This caused an error in Eclipse IDE. The error was however caused by Coden Analysis not finding the anomaly and so winging that the symbol could not be found. You can turn Coden off in Preferences under "General -> Startup/Shutdown" or change its behaviour in C/C++ Code analysis.
This may explain the sometimes random nature others are experiencing
回答6:
I think that you have not added header file that defines NULL . Add stdlib.h (#include statement). it defines NULL macros.
回答7:
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.
回答8:
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.
回答9:
Just add C:\MinWG\lib
to the Eclipse's Library Paths.
回答10:
I also encounter a similar problem which is "Symbol elf magic could not be resolved", and the elf header has already been included. I think that the problem may be caused by library cache,for restarting software can solve the problem. Thank for others' help.
回答11:
nothing of the suggestions above helped me. Every time opening a file the exclipse reports dozens of errors.
What helped in the end: Closing all files, then deleting the bugs manually (right click on the error list in the Problems window), then do a rebuild index.
回答12:
This problem is still coming up in 2019... there are many different causes/solutions.
I was getting unresolved symbols in the editor for NULL and everything in stdio.h (stderr, printf etc.) but compile worked fine. Nothing helped until I went in project properties and deleted a bunch of unnecessary C/C++ include paths. After that reindexing fixed the problem.
In another case I had an undefined symbol for a class name that was involved in some conditional preprocessor macro trickery. Adding the header file which defines the macro to "Index all variants of specific headers" in C/C++ indexer options (after checking "Enable project specific settings) fixed it.
This shows the the eclipse CDT indexer can get confused easily.
来源:https://stackoverflow.com/questions/7433448/eclipse-cdt-symbol-null-could-not-be-resolved