The only guaranteed size you can get in C ++ is char , unsigned char and signed char 2) which are always equal to one byte and are defined for each platform. 0) 1)
0) Although the byte does not have a specific size. sizeof(char) always 1 byte , but maybe 40 binary bits in fact
1) Yes, there are uint32_t and friends, but no, their definition is not necessary for real C ++ implementations. Use them, but you may get compile-time errors if they are not available (compile-time errors are always good)
2) char , unsigned char , and signed char are different types, and it is not determined whether char signed or not. Keep this in mind when overloading functions and writing templates.
Sebastian mach
source share