type casting problem

guy at rlgvax.UUCP guy at rlgvax.UUCP
Sat Jun 11 12:15:07 AEST 1983


Unfortunately, the V7 PDP-11 C compiler does not support "unsigned char".
The System III PDP-11 C compiler, and the C compiler on all later versions
of USG UNIX (USG UNIX n, for n >= 3.0), do support it.

If you take the term "char" at face value, there is no such thing as a "signed"
or "unsigned" char.  What is the sign of 'q'?  But since C doesn't have a
"veryshort int" (or "veryshort unsigned int") datatype, "char" is overloaded
to mean "one byte int" as well as "character".  I suspect "unsigned char"
was added because on all 11-family machines, "char" is signed, and somebody
wanted a more convenient way of getting an unsigned one byte integer.  On
some machines, the hardware supports both kinds, and can handle unsigned
characters more efficiently than by masking with 0377.  "unsigned char" is
guaranteed not to be signed, but "char" is not guaranteed to be either signed
nor unsigned; on the Western Electric 3B machines, "char" is unsigned.

		Guy Harris
		RLG Corporation
		{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list