unsigned what?
Guy Harris
guy at rlgvax.UUCP
Tue Jun 5 15:06:52 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
declaration
|
+------------+-----+----------+
| | |
decl-specifiers declarator-list ';'
| |
+--------------+ +---------+
| | |
type-specifier decl-specifiers init-declarator
| | |
'unsigned' type-specifier declarator
| |
'long' identifier
|
'l'
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".
This passage can either be interpreted as "if you leave all the type-
specifiers out, it's as if you put in 'int'" or "if you have nothing
but 'adjectives', it's as if you put in 'int'" (see the paragraph
containing the above passage, which describes "long", "short", and
"unsigned" as "adjectives").
So the exegesis is dependent on the interpretation of that passage;
the Ritchie and Johnson compilers both use the second interpretation.
Guy Harris
{seismo,ihnp4,allegra}!rlgvax!guy
More information about the Comp.lang.c
mailing list