Eclipse CDT "Symbol NULL could not be resolved"
Solution 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
Solution 2
As Bob mentioned, i fix the bug just by rebuilt the index
- right your project
- choose "Index"
- choose "Rebuild"
Solution 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.
Solution 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
Solution 5
I think that you have not added header file that defines NULL . Add stdlib.h (#include statement). it defines NULL macros.
Admin
Updated on July 23, 2022Comments
-
Admin almost 2 years
I just installed
Eclipse
CDT
withMinGW
. 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 theNULL
symbol :Symbol 'NULL' could not be resolved
Any insights? Thanks!
-
Keith Thompson over 12 yearsActually I don't think the standard headers include each other; each of the several headers that defines
NULL
does so independently. And you could define it yourself, but there's no good reason to do so; just include the header. -
Man Vs Code over 12 years@Keith - Perhaps on some systems, but on Linux, stdlib.h includes stddef.h. And here's an example on Google Code Search - [google.com/codesearch#XAzRy8oK4zA/libc/include/…
-
Keith Thompson over 12 yearsOk, but the effect is as if it didn't include it. This:
#include <stdlib.h> int main(void) { offsetof(struct { int i; }, i); return 0; }
fails to compile. -
Alex almost 8 yearsHave you encounter a similar problem yourself?
-
Admin almost 8 yearsyes , my problem is "symbol 'elf magic' could not be resolved"
-
Alex almost 8 yearsWelcome to SO. Some tips about posting answers. Post an answer if: 1. you encountered a similar problem and was able to resolve it. 2. You think your answer can contribute (e.g. your solution is different, or the problem is slightly different but related to the original). Include more details in your answer.
-
Andrés Alcarraz almost 6 yearsthis is not a solution to the problem it's just ignoring the symptom