Believe it or not I just read about this earlier today. Trying to determine "n-bit" types is actually kind of funky because there's no guarantee that things align to 8-bits.
- sizeof(char) is always 1. No exceptions.
- sizeof() returns the number of "byte"s.
- 1 "byte" is not necessarily 8 bits, but can be a larger number of bits
- 1 "byte" is a
minimum of 8 bits (can't be smaller, can be larger)
- CHAR_BIT in <climits> gives you the bitwidth of a "byte"
As for other types, I'm not sure what they're really defined as, but they probably must be all at least 1 byte in size (bools included -- although multiple bools might get "merged" into a bitfield by the compiler).
min/max ranges for types such as 'int' and 'long' can also be determined with <climits>, or possibly with <limits>... although <limits> can't be used in preprocessor #ifdefs =(
Source (and very interesting read):
http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.1
Anyway this all seems to reaffim my motto. typedef typedef typedef.