signed/unsigned char/short/int/long [was: #defines with parameters]

Piercarlo Grandi pcg at aber-cs.UUCP
Sun Dec 18 03:15:59 AEST 1988


In article <860 at quintus.UUCP> ok at quintus.UUCP (Richard A. O'Keefe) writes:

	[ on my suggestion to make "char int" denote guaranteed signed chars ]

    That change would *FORCE* compiler writers to break working code.

Why ever? I have never advocated removing the rule that "char" by itself is
either "int" or "unsigned", merely added a way to guarantee that it would be
signed.

    There are programs which were written for machines with unsigned chars
    (predating the introduction of 'unsigned char') where the programmers
    relied on the char range being 0..255.  While this was not _portable_,
    that implementation was _permitted_.  If you now rule that

	char = char int and is *signed*

Never implied this. (I care about backwards compatibility, even if I don't
like it where is rewards, like in your example, non portable practices).

    but X3J11 didn't introduce incompatibility lightly.

Yet it introduced an unnecessary keyword, the perpetuates the unfortunate
syntax that favors the confusions that "char" is indeed a type and "unsigned"
is indeed just a variant of "int".

    [ .... ] we _still_ want a way of saying "whichever of signed
    byte/unsigned byte is cheaper, I promise not to care".

Indeed!. Since 'char' is  to be a length modifier, I assumed it was obvious
that in case the base type is missing, it would default to either 'int' or
'unsigned', while for all other length modifiers it would always default to
'int'.

In dpANS C the rule is conversely that the type modifier 'signed' is the
default for all the lengths of 'int', but not for type 'char' where the
default may be either 'signed' or unsigned'.

    To be perfectly frank, I don't expect to have any use for 'signed char'.

I have, I have! (I mean "char int" of course). In many many cases one wants
to really consider "char" a length specifier, and create arrays of byte sized
integers or unsigneds (or don't cares).
-- 
Piercarlo "Peter" Grandi			INET: pcg at cs.aber.ac.uk
Sw.Eng. Group, Dept. of Computer Science	UUCP: ...!mcvax!ukc!aber-cs!pcg
UCW, Penglais, Aberystwyth, WALES SY23 3BZ (UK)



More information about the Comp.lang.c mailing list