In c++, specifically the cstdint header file, there are types for 8-bit integers which turn out to be of the char data type with a typedef. Could anyone suggest an actual 8-bit integer type?
Yes, you are right. int8_t
and uint8_t
are typedef
to char
on platforms where 1 byte is 8 bits. On platforms where it is not, appropriate definition will be given.
Following answer is based on assumption that char is 8 bits
char
holds 1 byte, which may be signed
or unsigned
based on implementation.
So int8_t
is signed char
and uint8_t
is unsigned char
, but this will be safe to use int8_t/uint8_t as actual 8-bit integer without relying too much on the implementation.
For a implementer's point of view, typedef
fing where char is 8 bits makes sense.
Having seen all this, It is safe to use int8_t
or uint8_t
as real 8 bit integer.