bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NULL macro


From: Simon Josefsson
Subject: Re: NULL macro
Date: Thu, 22 Jan 2009 01:37:50 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Peter Seebach and Simon Josefsson wrote:
>> > Note that NULL could
>> > be the same, or it could be already converted to (void *), so it depends on
>> > the implementation whether:
>> >
>> >    printf("%p\n", NULL);
>> >
>> > is legit.  (Which means it's not portable...)
>> 
>> Indeed, and a quite realistic example of where this bug hits in practice
>> is with the version-etc module where the final NULL needs to be
>> explicitly casted to work properly on all systems, e.g.:
>> 
>>       version_etc (stdout, "gsasl", p, gsasl_check_version (NULL),
>>                 "Simon Josefsson", (char *) NULL);
>
> That's true when you consider only ISO C99.

And C89/C90?

> But in POSIX, NULL is required to be (void *) 0. See
>   <http://www.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
> "The macro shall expand to an integer constant expression with the value 0 
> cast
>  to type void *."

Thanks for the reference.

/Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]