delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/03/06/09:58:11

X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs
Date: Mon, 6 Mar 2000 15:35:30 +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: <200003060929.KAA16122@mars.lu.erisoft.se>
Message-ID: <Pine.LNX.4.10.10003061514590.14313-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 Mon, 6 Mar 2000, Martin Stromberg wrote:

> > > No. The standard says NULL is defined in wchar.h and in stddef.h.
> > 
> > Yes but it does not say, it should be a specific macro, it just mean
> > that if one #include <wchar.h>  they can use NULL because it will be defined
> > Most <wchar.h> will just #include <stddef.h> to pull the relevant macros.
> 
> But for inttypes.h it explicitly says that inttypes.h #includes
> stdint.h. So I get the impression that files shouldn't #include each
> other unless it is stated. 

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. 

The new version may have some exceptions to this rule given explicitly,
but the general rule from old ANSI/ISO C89 still holds unchanged, in C99
(according to the last draft I grabbed):

Section 7.1.3, "Reserved identifiers"

        -- Each  identifier  with  file scope listed in any of the
            following  subclauses  (including  the  future  library
            directions)  is  reserved  for  use  as macro and as an
            identifier with file scope in the same  name  space  if
            any of its associated headers is included.

       [#2]  No  other  identifiers  are  reserved.  If the program
 
These two together mean that unless a program #include's a particular
header, none of the functions, types and macros it declares are allowed to
be predefined by the library. They must remain free for the program's own
use. If <wchar.h> #include'd <stddef.h>, e.g., the program would lose its
ability to define a type 'size_t' or 'ptrdiff_t'.

The reason for this is simple: without this mutual independence, the whole
point of having standard header files would be moot: the C Preprocessor
would just include all of them, by force, and no programmer would have
to 'waste his time' typing #include <stdio.h>.

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