From: Kim Barrett (kab_at_[hidden])
Date: 2006-06-08 13:29:02
At 12:51 PM -0400 6/8/06, Beman Dawes wrote:
>Gennaro Prota wrote:
> > * there is no guarantee that an unsigned char has 8 bits...
>The C and C++ standards specify char, signed char, and unsigned char all
>have exactly 8 bits, AFAIK.
CHAR_BITS is defined to be *at least* 8 bits. No guarantee that it is
*exactly* 8 bits. This is not just a historical artifact to support
strange ancient processors with odd addressing unit sizes either. There
are modern C/C++ implementations for modern DSP processors where, for
example, sizeof(char) == sizeof(int) == 1, and CHAR_BITS is 16 or 32
(or perhaps even 64, though I haven't actually run across that last
Of course, the vast majority of even purportedly portable code ignores
this fact, because it can be a real PITA to deal with, usually for little
or no benefit.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk