Subject: RE: `char -> unsigned char'
To: Don Lewis <Don.Lewis@tsc.tdk.com>
From: Martin Husemann <martin@rumolt.teuto.de>
List: current-users
Date: 12/20/1998 10:20:38
> Instead of casting, it may be cleaner to declare the relevant variables
> unsigned.  <stdio.h> also uses unsigned chars.  Alas, <string.h> uses
> signed chars.  So much for consistency.

Both would be violating the ANSI C library specs, but the code is a little
bit more subtle: the exported function prototypes have to use "char *" and
"const char *" as mandated by the ANSI spec, which does neither qualify as
"signed" nor "unsigned". Then there are declarations internal to our
implementation of stdio (i.e. in struct __sFILE) which are completely
private to our implementation and can use what they like.

In string.h there are only (ANSI mandated) function prototypes, which don't
qualify signed or unsigned (so you are wrong: string.h doesn't use signed
chars, it uses machine dependend chars, they are signed on the i386, but
unsigned on the powerpc, IIRC).

So the current code is consistent with the relevant standards and within
itself.

Alas, all this has nothing to do with the finger implementation, where we
obviously could chose to declare "unsigned char *" or "char *", whichever
needs less casting or is the minimal change.


Martin