|
Message-ID: <20130112064254.GF20323@brightrain.aerifal.cx> Date: Sat, 12 Jan 2013 01:42:54 -0500 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: NULL On Fri, Jan 11, 2013 at 11:56:02PM -0600, Rob Landley wrote: > On 01/09/2013 05:02:29 AM, John Spencer wrote: > >glibc defines NULL as __null: a magic variable supplied by GCC and > >compatibles which always has pointer context. > > > >musl defines NULL to 0 in C++. > >this is correct per the standard, but breaks a lot of software on > >64bit archs, > >because it promotes to int. > > The C99 standard section 7.17 defines the NULL macro as: > > expands to an implementation-defined null pointer constant > > Which means it has pointer type. So either we can typecast it to Nope, C is weirder than you think. A "null pointer constant" is defined as an integer constant expression with value zero, or such an expression cast to void *. So it need not have pointer type. > void *, or we can rely on the LP64 standard (Linux, FreeBSD, and > macosX all support) which says that long and pointer are always the > same size on both 32 bit and 64 bit, so trivial fix would be #define > NULL to (0L) Yes, using 0L on both C and C++ is the solution I'm leaning towards.. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.