Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Symbol 'NULL' could not be resolved(Can't resolve NULL with MinGW GCC, but can with Cygwin GCC)
Symbol 'NULL' could not be resolved [message #1090027] Mon, 19 August 2013 15:58 Go to next message
David Eisner is currently offline David EisnerFriend
Messages: 32
Registered: July 2009
Member
I'm using Eclipse Kepler and CDT 8.2 with a Makefile project.

When I use Cygwin GCC with the Gnu Make Builder (without Makefile generation), everything works fine.

However, when I use MinGW GCC as my toolchain (again with Gnu Make Builder), Eclipse can't resolve the standard NULL macro. Index > Rebuild at the project node doesn't help.

I'm using MinGW 4.6.2. Any ideas? I've included a screen capture, if that helps.

-David

Re: Symbol 'NULL' could not be resolved [message #1090088 is a reply to message #1090027] Mon, 19 August 2013 17:43 Go to previous messageGo to next message
ArbolOne Mising name is currently offline ArbolOne Mising nameFriend
Messages: 10
Registered: December 2010
Junior Member
show the code, it might help. However, don't cut and paste, type the code in Notpad and then C&P. While retyping the code you just might find the answer to it. Some times one compiler skips one thing, but the other won't. It has happened to me many times when porting libraries.
Re: Symbol 'NULL' could not be resolved [message #1090129 is a reply to message #1090088] Mon, 19 August 2013 18:47 Go to previous messageGo to next message
David Eisner is currently offline David EisnerFriend
Messages: 32
Registered: July 2009
Member
What you see in the screen capture is all there is. I reproduced the problem with the simplest possible example: A one file project, just main.c with three statements:

--snip--
#include <stdio.h>
#include <stdlib.h>


int main( int argc, char *argv[]) {

    char *p = NULL;


    if (p)
        printf( p );
    else
        printf( "NULL\n");

    exit(0);
}
--snip--

My "real" project has thousands of files, and exhibits the same problems. This is just an SSCCE. [1]

-David

[1] http://sscce.org/
Re: Symbol 'NULL' could not be resolved [message #1090140 is a reply to message #1090129] Mon, 19 August 2013 19:06 Go to previous messageGo to next message
David Eisner is currently offline David EisnerFriend
Messages: 32
Registered: July 2009
Member
OK, I've narrowed down the problem: I am using MinGW 4.7.2, *NOT* 4.6.2 as I erroneously reported. In my initial post I was dutifully repeating the version number I saw in the "Includes" paths in the Project Explorer view in Eclipse, but the actual paths on my system are all under

C:\MinGW\lib\gcc\mingw32\4.7.2

and *not* C:\MinGW\lib\gcc\mingw32\4.6.2 (see the screen capture from the first post).

So the question is: why does Eclipse use 4.6.2 and not 4.7.2 in the Includes? Do I need to edit the toolchain definition somehow?

-David
Re: Symbol 'NULL' could not be resolved [message #1090732 is a reply to message #1090140] Tue, 20 August 2013 15:06 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Which version of MinGW is in your PATH variable defined? It should 4.7.2 if you want to use it.
"To forget" the old include paths: Open Project Properties->C/C++ General->Preprocessor Include Paths and clear the entries for Built-in Compiler settings.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Symbol 'NULL' could not be resolved [message #1090792 is a reply to message #1090732] Tue, 20 August 2013 16:50 Go to previous message
David Eisner is currently offline David EisnerFriend
Messages: 32
Registered: July 2009
Member
Alex, thanks -- your advice got me to where I needed to go. I only had one version of MinGW installed, but I believe I had the older version installed when I installed Eclipse.

Here are the details if anybody else has this problem:

I couldn't clear the settings from the Entries tab, but your suggestion got me to Project Properties > C/C++ General > Preprocessor Include Paths > Providers (tab). When I selected the "CDT GCC Built-in Compiler Settings MinGW [ Shared ]" entry, the Language Settings Provider Options panel appeared, with this information: "Options of global providers below can be changed in (linked->) Workspace Settings, Discovery Tab."

Clicking the link brought me to a dialog I could have reached directly with Eclipse Menu > Window > Preferences > C/C++ > Build > Settings > Discovery (tab). I selected "CDT GCC Built-in Compiler Settings MinGW [ Shared ]", and pressed the Clear Entries button. Then I pressed the Apply button (OK probably would have worked, too), and I was good to go.

Thanks again.



Previous Topic:Auto-insert Switch/Case & Do/While incorrect
Next Topic:How to work with unit testing for C code
Goto Forum:
  


Current Time: Tue Apr 16 20:59:46 GMT 2024

Powered by FUDForum. Page generated in 1.70683 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top