On Jul 3, 2012, at 11:24 AM, 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.
OK, yes, the minimums are defined. I've actually run into much more
trouble when people assume a maximum, the crypto example I mentioned
before being the big one (where you're using integer overflow to
perform addition/multiplication/etc modulo 2^32). That's not short,
obviously, but a short could be 128 bits if a long were 256. It
wouldn't be illegal, and might be totally logical on the host
architecture (though it's obviously in the realm of fantasy for the
nonce).
- Dave