Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 11 Jan 2013 23:56:02 -0600
From: Rob Landley <rob@...dley.net>
To: musl@...ts.openwall.com
Cc: musl@...ts.openwall.com, Luca Barbato <lu_zero@...too.org>,
	basile@...nsource.dyc.edu
Subject: Re: NULL

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 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)

   http://www.unix.org/whitepapers/64bit.html

Rob

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.