Mail Archives: djgpp-workers/2000/03/06/09:58:11
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 -