Signage on Acorn?

Richard A. O'Keefe ok at atlas.otago.ac.nz
Thu Apr 27 02:54:49 UTC 2000


Concerning the signed/unsigned char bug,
someone wrote:
	> Hey Tim, now you get to explain why the Acorn version works
	? eh?  Which compiler isn't standard?
and Time replied:
	I think that it's a case of there being no actual standard.

Well, not exactly.  The C89 standard describes three *distinct* types:
	signed char (SCHAR_MIN to SCHAR_MAX)
	unsigned char (0 to UCHAR_MAX)
	char (CHAR_MIN to CHAR_MAX)
and explicitly says it is implementation-defined whether char behaves
like signed char (which is what the PDP-11 did)
or like unsigned char (which is what the /370 port of C did).
It's one of those things that are deliberately left sloppy so that
if you don't care, the compiler can pick whatever works best on your
machine.  In fact there's one more rule:  all of the characters used
by C itself must fit in a 'char'.  So if you use some version of EBCDIC
as your execution character set, you pretty much have to use the
unsigned interpretation of char, but if you use ASCII, you can use either.

Implementation-defined means that the implementors must _tell_ you what
they chose.  In this case, you can easily find out by testing whether
CHAR_MIN != 0.  I find myself using unsigned char a lot...





More information about the Squeak-dev mailing list