www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/17/05:10:52

X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs
Date: Mon, 17 May 1999 10:33:44 +0200 (MET DST)
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: wctype.h and ctype.h
In-Reply-To: <Pine.SUN.3.91.990516133351.26252C-100000@is>
Message-ID: <Pine.LNX.3.93.990517100828.2286C-100000@acp3bf>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


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