unsigned what?

Morris Keesan keesan at bbncca.ARPA
Wed Jun 13 00:40:37 AEST 1984


------------------------------
> > strict exegesis (or pilpul, depending on your religion) of K & R indicates
> > that the strings
> 
> > 		  unsigned short
> > 		  unsigned char
> > 		  unsigned long
> 
> > do not denote legitimate types in C, yet I see these in various places (some
> > Berkeley header files, for example). Have these types been blessed somewhere
> > (like the enum types) without mention?
> 
> "unsigned long l;" parses as
> 		      .
> 		      .     [parse diagram omitted]
> 		      .
> and is equivalent to "unsigned long int l;"; the key passage is in
> the C Reference Manual, "8.2 Type specifiers":
> 
> 	  If the type-specifier is missing from a declaration, it is
> 	  taken to be "int".
> 
> 	  Guy Harris
> 	  {seismo,ihnp4,allegra}!rlgvax!guy

Actually, the key passage is in the same section Guy cites, just prior to his
citation:

	    The words long, short, and unsigned may be thought of as
            adjectives; the following combinations are acceptable.

		short int
		long int
		unsigned int
		long float

The above is from K&R, and therefore the original poster was right:  by
omission, strict exegesis of K&R forbids any other combinations.  The passage
as above also appears in the C Reference Manual in the UNIX V7 documentation.
The System V documentation (and perhaps earlier USG/UGLIX versions of C) add
unsigned char to the list of acceptable combinations (page 89 of System V
"Programming Guide"), so it has been "blessed somewhere", but not without
mention (similarly enum types are mentioned, if you know where to look for
them).  The remaining two forms, unsigned short and unsigned long, are not
blessed by any Bell Labs documents that I know of.  I know that by adding the
two types "unsigned char" and "void" to our V7 C compiler (along with some
changes, but without the addition of the two disputed "unsigned" types), we were
able to successfully compile all of the System V source.  Apparently the long
and short of it are Berkeleyisms.  Can anyone confirm this?  Is there a manual
for Berkeley C?
-- 
					Morris M. Keesan
					{decvax,linus,wjh12,ima}!bbncca!keesan
					keesan @ BBN-UNIX.ARPA



More information about the Comp.lang.c mailing list