> "long int" is a guaranteed 4-byte value.
> "short int" is a guaranteed 2-byte value.
Richard,
This is not quite correct (or, at best, is ambiguous). From my favorite C
manual ("C: A Reference Manual", by Harbison and Steele, 4th edition):
"The C language does not specify the range of integers that the integral types
will represent, except to say that type 'int' may not be smaller than 'short'
and 'long' may not be smaller than 'int'. Many implementations represent
characters in 8 bits, type 'short' in 16 bits, and type 'long' in 32 bits, with
type 'int' using either 16 or 32 bits depending on the implementation. ISO C
requires implementations to use at least these widths."
So, the sizes can be larger in any compliant compiler, and may be smaller in a
non-compliant (pre-ISO) compiler.
-- Keith
"Richard M. Hartman" <[EMAIL PROTECTED]> on 02/10/2001 12:39:26 AM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: "Richard M. Hartman" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/US/PALM)
Subject: Re: ShlPrintf bus error
Steve Orens <[EMAIL PROTECTED]> wrote in message news:38949@palm-dev-forum...
...
> Well, it looks like that helped. I switched from using %ld to %d and it
> doesn't crash anymore.
>
> I guess I have always assumed that it was safe to print to use %ld (on
other
> platforms, I've been able to inter-change %ld and %d with no
consequences).
> Guess I will need to change my asssumption!
"int" is a tricky thing in C.
"long int" is a guaranteed 4-byte value.
"short int" is a guaranteed 2-byte value.
But "int" (unadorned by modifier) is the value that is most "natural" to the
processor.
--
-Richard M. Hartman
186,000 mi/sec: not just a good idea, it's the LAW!
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/