Mail Archives: djgpp-workers/1999/05/17/05:10:52
On Sun, 16 May 1999, Eli Zaretskii wrote:
> On Thu, 13 May 1999, DJ Delorie wrote:
>
> > It wrong for wctype.h to include inlines/ctype.ha. It should include
> > inlines/wctype.ha if it has inline functions.
>
> Why can't wctype.h use inlines/ctype.ha, if it needs it? Does the
> standard preclude it?
Unless I misread Plauger's 'The Standard C Library', it does. In a
nutshell: any interdependency between the standard C headers is forbidden.
Nothing that is defined by header <foo.h> may be defined just because you
#include another standard header.
This is for keeping the namespace clean; so if you don't #include, say,
ctype.h, you can write your own function isupper(), and none of the other
library functions (outside <ctype.h>) is allowed to change behaviour
because of this.
This rule alone doesn't disallow #include <inlines/ctype.h> inside
<wctype.h>, yed. But the fact that <inlines/ctype.ha> does contain lines
like
#define isupper(c) ....
does. This would have to be changed. Unless I'm totally off track, here,
<wctype.h> needs its own <inlines/wctype.ha>, instead of including the one
from <ctype.h>.
> How about including ctype.h from wctype.h? Will that be good enough?
That's forbidden by the standard, by induction from what I said above. No
standard header inclusion is allowed to effect inclusion of any other
standard header.
The basis of this is a bit hard to isolate from the text of the standard,
though, so let me show it. Quote is from C9x draft, but this paragraph is
unchanged from C89, it seems. It's in 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
[...]
Together, these two clauses mean: standard library function names are only
reserved *if* you #include the standard header that defines them. Turning
this around, you get that if the program doesn't #include <ctype.h>, the
compiler may not assume anything about isupper(). This then precludes that
#include <wctype.h> could #include <ctype.h> or its corresponding inlined
version behind the users back.
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -