I need your help tracing the source of this problem. A recent thread on the C++ forum about the NULL keyword shown a problem with the macros being defined on my MinGW installation. I'm confident this is my problem. Not the implementation's. I just need to understand what I'm doing wrong.
Problem:
The following C++ code generates warning: converting to non-pointer type `int' from NULL
The code is compiled with:Code:#include <cstdlib> int main() { int p = NULL; }
Delving inside the mingw header files reveals that <cstdlib> includes <cstddef>. And this last one includes stddef.h. And this is what I find around the macro definition for NULL:mingw32-g++.exe -c -O0 -o "C:/test/Debug/main.o" -IC:/MinGW/lib/gcc/mingw32/3.4.5/include/
-IC:/MinGW/include/c++/3.4.5/backward/
-IC:/MinGW/include/c++/3.4.5/mingw32/
-IC:/MinGW/include/c++/3.4.5/
-IC:/MinGW/boost/include/boost-1_33_1/
-IC:/MinGW/include/sqlite/
-IC:/MinGW/include/
"main.cpp" -Wall -Wextra -ansi -pedantic -g3
It seems __cplusplus is not being defined anywhere and NULL is being defined in the C form.Code:#if defined (_STDDEF_H) || defined (__need_NULL) #undef NULL /* in case <stdio.h> has defined it. */ #ifdef __GNUG__ #define NULL __null #else /* G++ */ #ifndef __cplusplus #define NULL ((void *)0) #else /* C++ */ #define NULL 0 #endif /* C++ */ #endif /* G++ */ #endif /* NULL not defined and <stddef.h> or need NULL. */ #undef __need_NULL
Do you have any idea what is wrong?