unsigned char -> unsigned int conversion

Morris Keesan keesan at bbncca.ARPA
Thu Jun 21 01:37:12 AEST 1984


-----------------------------
> The C Reference Manual that's part of the K&R book is a little vague
> on the subject of what types "unsigned" can be applied to.  In the
> detailed discussion it says that "unsigned int" is the only legitimate
> form, but elsewhere it implies the existence of "unsigned long" in
> some implementations.
> 
> Note that even the V7 compiler accepts "unsigned short".
>     . . .
> 				  Henry Spencer @ U of Toronto Zoology

    I'm well familiar with the "detailed discussion" (section 8.2), since I've
been citing it a lot recently, but where "elsewhere" does it "imply" unsigned
long?

    I checked BBN's C compiler for our C/70 machine, which is based on the
V7 PDP-11 C compiler, and found that it does indeed accept "unsigned short".
Curious, I checked to see why and discovered that it's because "short" is
defined as lexically equivalent to "int".  This results in the amusing
behaviour of the compiler accepting "unsigned short" (equivalent to "unsigned"
or "unsigned int"), but rejecting "short int" (because it looks like "int int").
I'd be interested in knowing whether this happens in real V7 compilers, or only
in BBN's.
-- 
					Morris M. Keesan
					{decvax,linus,wjh12,ima}!bbncca!keesan
					keesan @ BBN-UNIX.ARPA



More information about the Comp.unix.wizards mailing list