[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: definition of NULL correct?
On Tue, Aug 11, 2009 at 4:32 PM, Greg Troxel<gdt%ir.bbn.com@localhost> wrote:
> We define NULL as "(void *)0" rather than "((void *)0)", and that causes
> sizeof NULL
> to fail.
Wouldn't it more be a gcc issue where it treats the expression as what
c99 defines as "sizeof (type-name)" (cf section 6.5.3) leaving the "0"
as a syntax error rather than interpreting the cast and treating the
sizeof expression as "sizeof unary-expression" ? I'm not sure about
the precedence of the cast operation over the 'sizeof' operator.
C99 defines a "null pointer constant" as "an integer constant
expression with the value 0, or such an expression cast to type void
*" (cf section 184.108.40.206). Section 7.17 precise that what NULL expands
to is implementation defined.
I've not been to find anything about NULL in POSIX 2008...
> I found this in libunistring:
> Here is an example program, which fails to build on NetBSD 5 (i386).
> Some of the gnulib people think that this is a failure of NetBSD to
> comply with POSIX 2008.
> #include <stdlib.h>
> #include <stdio.h>
> printf("null size is %zd\n", sizeof NULL);
> return 0;
Main Index |
Thread Index |