Boost logo

Boost :

From: Kim Barrett (kab_at_[hidden])
Date: 2006-01-12 15:49:55


At 9:17 AM -0600 1/12/06, Chris Cleeland wrote:
>On Fri, 13 Jan 2006, Christopher Kohlhoff wrote:
> > - Does unsigned char always imply 0..255?
>
>Good question; I know that sizeof(char) == sizeof(unsigned char) == 1, but I
>don't know that it's guarantee anywhere that something that has a sizeof==1
>is exactly 8 bits.
>
>That said, I can't think of any implementation anywhere that I've encountered
>otherwise, including some pretty arcane old hardware architectures. As you
>somewhat imply, porting code that deals in octets to such an architecture
>would be pretty difficult, to say the least.

No, CHAR_BIT is only required to be *at least* 8. It is pretty common for
DSP platforms to have char, short, and int all be of the same size
(either 16 or 32 bits, or perhaps even 64 bits for some these days,
depending on the specific model of DSP). This is all driven by a
combination of the smallest addressable unit and the native data unit
(i.e. register) size. General purpose processors have pretty much settled
on 8 bit addressable units (there used to be others, I'm pretty sure I
remember 9, and I think 12), but the DSP world is quite different (though
powers of 2 seem to have won there too).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk