Well, I'm not a desk-top chauvinist, otherwise I wouldn't have bothered at
all.
Actually, I was a bit inaccurate in my original question, because what I'm
concerned with is not a _sizeof_ value of type _long_, rather number of bits
in the type. Most of the calculations in my program require only 16-bit size
variables, but in some cases 32-bit ones are necessary. For 16-bit
calculations I use type _int_, for 32-bit type _long_, even though they are
of the same 32-bit size on my desktop. I'm deliberately using type _long_
with the portability concern in mind. The good news in your post is that the
2 imbedded processors you mentioned do have 32-bit long.
Cheers,
Nikolai Borissov
One possibility is to use a version of the latest C standard's
<inttypes.h>, which is likely to make it into the next update to the
C++ standard.
Almost all platforms have integer types that meet the requirements
(with the exception of those DSPs I mentioned above), so you can
tailor it accordingly.
That way you can use int16_t when you want a value that can hold 16
bits, and int32_t when you need more range.
On a typical 32 bit compiler, int32_t would be a typedef for int, on a
16 bit compiler, a typedef for long.
Likewise int16_t would be a typedef for int on a compiler with 16 bit
ints, and for short on a typical 32 bit desk top compiler.
The C++ standard specifies the minimum ranges of values that each of
the integer types must hold, and it inherits those values from C.
Given that a pure binary notation is required for the integer types,
it is easy to work out the minimum number of bits each type must
contain:
8 bits for the character types
16 bits for short and int
32 bits for long
64 bits for long long (another C99 feature likely to make in into
the next update of the C++ standard)
So on any conforming C or C++ implementation, long must have at least
32 bits.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq