Oct 9, 2012 at 5:00pm UTC
In the library "stddef.h" I find out this line of code:
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
/* shield NULL definition for non-gnu parsers */
>>new<< #ifndef __cplusplus
>>new<< #define NULL ((void *)0)
>>new<< #else
>>new<< #define NULL 0
>>new<< #endif /* __cplusplus */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
as you can see NULL is defined as __null. My question is this: where is __null defined?
Oct 9, 2012 at 5:24pm UTC
It might be defined by the compiler. Double underscores in front usually indicate a compiler-specific keyword. The fact that it's within a compiler #ifdef also suggests that.
Though in C++11 you don't really need NULL or __null because there's a standard nullptr
keyword that is widely implemented.
Oct 9, 2012 at 5:38pm UTC
Hmm got it. Thanks you very much:)
Oct 10, 2012 at 9:31am UTC
By the way if I wanna see the code of the compiler (to find out the declaration of the __null) , where do i have to look at?
p.s. I'm curious
Last edited on Oct 10, 2012 at 9:32am UTC