delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/03/08/05:44:16

X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs
Date: Wed, 8 Mar 2000 11:29:22 +0100 (MET)
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
X-Sender: broeker AT acp3bf
To: djgpp-workers AT delorie DOT com
Subject: Re: iso646.h and some questions
In-Reply-To: <200003080806.JAA17092@mars.lu.erisoft.se>
Message-ID: <Pine.LNX.4.10.10003081112290.16372-100000@acp3bf>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019