On Thu, May 30, 2002 at 01:48:09PM -0400, Stringer wrote:
> Nope. The only size requirement is sizeof(short) <= sizeof(long)
> There's no set size for 'short', 'int' or 'long'
>
> And there's no gaurentee of sizeof(short) <= sizeof(int)
> or of sizeof(int) <= sizeof(long)
>
> In theory 'int' could be larger than 'long' or smaller than 'short', though
> all processors you are currently likely to run into seem to have
> sizeof(short) <= sizeof(int) <= sizeof(long)
Uh... okay, if we're going to be pedantic, and if we're going to worry
about this stuff, let's be *right*. (In the following, I'm going to
simplify by assuming that we're dealing with the binary two's-complement
layouts we all know and love.)
Standard C and C++ provide the following guarantees, except that
"long long" does not exist in standard C++:
|char| >= 8 bits
|short| >= 16 bits
|int| >= 16 bits
|long| >= 32 bits
|long long| >= 64 bits
|char| <= |short| <= |int| <= |long| <= |long long|
ISO/IEC 9899:1999 (the C99 standard) specifies the minimum sizes for
each type in section 5.2.4.2.1 and the progression amongst them in
sections 6.2.5/8 and 6.3.1.1.
ISO/IEC 14882 (the C++ standard) specifies the progression of sizes in
3.9.1 [basic.fundamental]/2. It specifies the minimum sizes in 18.2.2
[lib.c.limits], which references C90's 5.2.4.2.1 -- and section 1.2
[intro.refs] specifies that referenced provisions of C90 are provisions
of C++. (And C90's 5.2.4.2.1 is the same in these respects as C99's.)
And if you assume m68k Palm OS, you can be much more precise about these
things. Like saying "short" is 16 bits. That's guaranteed by the m68k
Palm OS ABI, such as it is.
John "any questions? :-)"
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/