On Tue, 3 Jul 2012, Sean Conner wrote:
But sizeof(unsigned short) is *still* defined (same
section as above).
The ANSI C specification states that a short shall be *at least* 16 bits in
size, but can be larger, but must be shorter than a long. If the compiler
isn't ANSI C, then yes, it can be pretty much anything, but ANSI does
specify a minimum length.
Not all of us are enthusiastic, EVEN NOW, about switching from defacto
practices in K&R to arbitrary standards in ANSI-C
And for the record:
char 8 bits or larger [1]
short 16 bits or larger
In K&R C, a short int was often the same as a char
An int can't be shorter than a short, and
can't be longer than a long.
That's what K&R originally said, also, and that THAT was ALL that one
should assume.
They said that an int should be whatever was best handled by the machine.
[1] a plain 'char' declaration can be signed
or unsigned, depending upon
compiler.
THAT one bit me, and hard, when I was first starting, and using char for
byte (contents of 8 bit registers, etc.).