开发者

Eclipse CDT "Symbol NULL could not be resolved"

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? 开发者_StackOverflowThanks!


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


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

  1. right your project
  2. choose "Index"
  3. choose "Rebuild"


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.


  • 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

Eclipse CDT "Symbol NULL could not be resolved"

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


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


I think that you have not added header file that defines NULL . Add stdlib.h (#include statement). it defines NULL macros.


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.


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.


Just add C:\MinWG\lib to the Eclipse's Library Paths.


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.


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.


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜