Eric Blake <ebb9 <at> byu.net> writes: > > Indeed, "sizeof (void*)0" parses as sizeof of the type 'void *', followed by a > > stray 0 token => parse error. > > I argue that NetBSD's definition of NULL is thus buggy, and that we should add > a gnulib check and config.h workaround for it. POSIX requires: > > "The macro shall expand to an integer constant expression with the value 0 cast > to type void *." > > which implies to me that I should be able to use NULL without having to add > extra parenthesis myself.
The one quote listed above is insufficient (it came from XBD 13, http://www.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html#tag_13_47) . But coupled with this additional quote from POSIX XSH 2.1.2, I can back up my claim that since NULL is an object-like macro, and nothing in <stddef.h> specifies to the contrary, NULL shall be properly protected by parentheses - hence NetBSD NULL does not comply with POSIX 2008. "Each of the following statements shall apply to all macros unless explicitly stated otherwise: 1. Any definition of an object-like macro in a header shall expand to code that is fully protected by parentheses where necessary, so that it groups in an arbitrary expression as if it were a single identifier." http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_0 1 -- Eric Blake