I know that the C/C++ standards only guarantee a minimum of 8 bits per char, and that theoretically 9/16/42/anything else is possible, and that therefore all sites about writing portable code warn against assuming 8bpc. My question is how "non-portable" is this really?
Let me explain. As I see it, there a 3 categories of systems:
char
is not exactly 8 bits. (please correct me if I am wrong)char
is more tham 8 bits, I have not heard of one to date (again, please inform me if I am just unaware)Bottom line: Are there common (more than %0.001) platforms (in categories 1&2 above) where char
is not 8 bits? And is my above surmise true?
use limits.h
CHAR_BIT
http://www.cplusplus.com/reference/clibrary/climits/
also, when you want to use exactly a given size, use stdint.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With