Mail Archives: djgpp-workers/2000/03/08/05:44:16
On Wed, 8 Mar 2000, Martin Stromberg wrote:
> > On Mon, 6 Mar 2000, Martin Stromberg wrote:
> > In the actual standard, it's even quite a bit stronger than that: none of
> > the standard headers is *allowed* to just #include any of the others.
> > They're supposed to be choosable 100% independantly.
[... standard quoted ...]
> This passage is in the standard exactly as quoted here.
I thought so. Thanks for double-checking.
[...]
> So what do we do about NULL, that should be in both wchar.h and
> stddef.h?
Just add the same two lines to wchar.h that are already in all the other
ANSI headers that also define NULL (it's defined by half a dozen of
them...):
#undef NULL
#define NULL 0
This not a particularly nice technique, but it works. For a more
'organized' solution, a common <sys/null.h> or similar might be used. For
a case as simple as NULL, it's not strictly necessary, of course, but it's
still a good idea to keep everything defined in exactly one place, instead
of having several definitions of it floating around.
A different technique (used by P.J.Plauger in his excellent book The
Standard C Library) is to collect all the vital #defines that are
system-dependent into a single header file (he calls it <yvals.h>):
<sys/sysconf.h> would have the 'central' definition:
#define _NULL 0
and all other headers that want to define NULL would then
#include <sys/sysconf.h
#undef NULL
#define NULL _NULL
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -