This is the mail archive of the newlib@sourceware.cygnus.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Definition of NULL. (fwd)


Joel Sherrill wrote:
> 
> An RTEMS user recently noticed that the newlib definitions of NULL are not
> proper.  The proper definition is apparently "0" or "(void *)0".  The
> offending definitions are in:
> 
> stdio.h:#define NULL    0L
> stdlib.h:#define NULL 0L
> string.h:#define NULL 0L
> time.h:#define  NULL    0L
> 
> In newlib/libc/include.  There may be others in machine and OS specific
> files.

Even more interestingly, the "one true" definition is in stddef.h. This is
because if you have included this file from c++ sources, using g++, then you
actually want the definition to be g++'s internal symbol __null. This is all
wrapped up in stddef.h.

So I think that in addition to changing these instances to (void *)0 (which
is the most correct) anyway, we should also #define __need_NULL before
including <stddef.h> so that we pick up the compiler's idea of NULL if
possible.

Jeff?

Jonathan L.
-- 
Cygnus Solutions, 35 Cambridge Place, Cambridge, UK.  Tel: +44 (1223) 728762
"It is impossible to enjoy idling thoroughly unless||Home e-mail: jifl @ 
one has plenty of work to do - Jerome K. Jerome"   ||     jifvik.demon.co.uk
Help fight spam! http://spam.abuse.net/  These opinions are all my own fault