The <cstdint> (<stdint.h>) header defines several integral types and their names follow this pattern: intN_t, where N is the number of bits, not bytes.
Given that a byte is not strictly defined as being 8 bits in length, why aren’t these types defined as, for example, int1_t instead of int8_t? Wouldn’t that be more appropriate since it takes into account machines that have bytes of unusual lengths?
On machines that don’t have exactly those sizes the types are not defined. That is, if you machine doesn’t have an 8-bit byte then
int8_twould not be available. You would still however have the least versions available, such asint_least16_t.The reason one suspects is that if you want a precise size you usually want a bit-size and not really an abstract byte size. For example all internet protocols deal with an 8-bit byte, thus you’d want to have 8-bits, whether that is a native byte size or not.
This answer is also quite informative in this regards.