In said:
Really! Try to find a chapter and verse prohibiting it! The only such
prohibition is explicitly related to standard header inclusion:
7.1.2 Standard headers
....
4 ... The program shall not have any macros with names lexically
identical to keywords currently defined prior to the inclusion.
^^^^^^^^^^^^^^^^^^^^^^
Such a specification would be completely superfluous in the library
clause if the language prohibited the definition of such macros. Instead,
the standard explicitly says:
6.4.1 Keywords
....
2 The above tokens (case sensitive) are reserved (in translation
^^^^^^^^^^^^^^
phases 7 and 8) for use as keywords, and shall not be used
^^^^^^^^^^^^^^
otherwise.
Then the following should also be allowed, but GCC
chokes on it:
#include <stddef.h>
#define void
int main(void) {
int *p = NULL;
return 0;
}
You can't prove anything about the C standard by invoking the behaviour
of one implementation.
This is a known problem with the C standard and it poses a problem
to implementors who want to get it right: they can't use *any*
keywords in their macro definitions, they have to replace them by
reserved identifiers. A *correct* <stddef.h> would have to contain
code like this:
#ifndef __VOID
typedef void __void;
#define __VOID
#endif
#ifndef NULL
#define NULL ((__void *)0)
#endif
The typedef is safe, because void can't be a macro at the time a standard
header is included and __void is an unconditionally reserved identifier.
In this particular case, it's much easier to define NULL as a plain 0 and
get rid of all the complications, but there are other standard macros
that must be carefully defined to survive this kind of abuse.
Dan