🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9610

Re: Signed char - What Foolishness Is This!

#9610
From: Doug Gwyn
Date: Sun, 19 Oct 1986 02:08
33 lines
1987 bytes
In article <8719@duke.duke.UUCP> jwg@duke.UUCP (Jeffrey William Gillette) writes:
>     #define isupper(c)     ( (_ctype+1)[c] & _UPPER )
>
>The problem here lies with Microsoft.

No, the problem lies with the programmer.  The is*() functions have
(int), not (char), arguments.  When you feed one a (char), it will
be promoted to an (int) by the usual rules, including possible sign
extension.  The macro definition acts the same as a function in this
regard, since array indices are (int), not (char), also.  Microsoft's
definition is correct.

>1)      Do other C compilers make 'char' a signed quantity by default?

Dennis Ritchie's original (PDP-11) C compiler did.

>2)      What possible justification is there for this default?

(a) less cost on machines like the PDP-11

(b) the programmer can, using suitable code, force whatever behavior
	he wants

>I mean is, what is the definition of a negative 'a'?

It might surprise you to learn that 'a' represents an (int) constant,
not a (char).  C (char)s are just short integral types whose signedness
depends on the implementation (however, (signed char) and (unsigned char)
have definite signedness).  Dennis intended that sizeof(char)==1 but
I can make a strong argument that that isn't necessary.

P.S.  I suggest people learn what is going on before raving about it.
That would sure reduce the noise level of net.lang.c.
Technical Details
Message-ID: <4722@brl-smoke.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!brl-adm!brl-smoke!gwyn
References: <8719@duke.duke.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: Signed char - What Foolishness Is This!
Message-ID: <4722@brl-smoke.ARPA>
Date: Sat, 18-Oct-86 22:08:52 EDT
Article-I.D.: brl-smok.4722
Posted: Sat Oct 18 22:08:52 1986
Date-Received: Tue, 21-Oct-86 22:24:59 EDT
References: <8719@duke.duke.UUCP>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 33