Re: sizeof(char

Richard B. Johnson (root@chaos.analogic.com)
Thu, 22 Jan 1998 18:48:27 -0500 (EST)


On Thu, 22 Jan 1998, Marc Lehmann wrote:

>
> it might be worth to note that sizeof(char)==1, ALWAYS, on every
> architecture, on all iso c compliant systems.
>
> char _is_ the smallest addressable unit, and sizeof() doesn't
> measure bytes but storage units, so this equation holds without
> problems.
>

You are correct. However, the 'C' standard didn't recognize that it
is possible to address a single bit in memory on several architectures.
This means that, interpreted literly, sizeof(8BIT_OBJECT) would be 8!
Then there is the problem with nibble-based systems like the '360. The
smallest addressable storage unit is 4 bits. This would make such
an interpretation of sizeof(8BIT_OBJECT) == 2.

Once 'C' is ported to an old IBM/360 this problem will have to be
addressed <grin>. In the meantime, it is assumed that the smallest
storage unit is 8 bits even though a char object isn't necessarily
this size.

Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.80 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.