tech-userlevel archive

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

Bogus ifdef guard in sys/null.h



Hi people,

in http://grok.x12.su/source/xref/netbsd/sys/sys/null.h ,
the _SYS_NULL_H guard is bogus, since the whole header defines NULL
only. And there's already a guard for NULL. The code as it is, breaks
the following snippet:

% cat t.c
#include <stddef.h>
#undef NULL
#include <unistd.h>

int
main(void)
{
    void *p = NULL;

    return 0;
}
% gcc t.c
t.c: In function 'main':
t.c:8: error: 'NULL' undeclared (first use in this function)
t.c:8: error: (Each undeclared identifier is reported only once
t.c:8: error: for each function it appears in.)
%

POSIX says that both stddef.h and unistd.h shall provide NULL. This
isn't just a thought experiment. It actually broke a test from here:
http://www.itl.nist.gov/div897/ctg/posix_form.htm

Please consider changing it, or explain why it shouldn't.


Best regards,
Stathis


Home | Main Index | Thread Index | Old Index