Wed, 11 Nov 1998 21:17:08 +1100
|
"W. Wesley Groleau x4923" wrote:
>
> My C books emphasize the fact that the size and range of anything other
> than "char" is not portable.
Even char is not portable!
It is signed on some platforms (range -128 .. 127)
and unsigned on others (range 0 .. 255).
This has caused me huge headaches porting code taht
had been written with no respect for this fact.
Actually the ranges above are not guaranteed, only typical.
By definition sizeof(char)==1 but a char is not necessarily 8 bits.
As Stroustrup wrote in 'The C++ Programming Language':
"Writing truly portable low-level code is harder ... it is usually safe
to assume that a char can hold integers in the range 0 .. 127"
Of course, with Ada, we don't have to "assume" anything,
and we don't have to write programs that "usually" work.
And writing truly portable code is generally not that hard.
Cheers
Geoff
|
|
|