The fixed-width integer types provided by <inttypes.h> include
both signed and unsigned integer types, such as int8_t
, int16_t
, int32_t
, int64_t
, uint8_t
, uint16_t
, uint32_t
, and uint64_t
. Derived types defined
as the smallest integer types that can hold the specified number of bits include int_least8_t
, int_least64_t
, uint_least8_t
, uint_least64_t
.
These fixed-width types should not be used indiscriminately.
For example, int
can continue to be used for such things as loop counters
and file descriptors, and long
can be used for array indices. On the
other hand, you should use fixed-width types for explicit binary representations of:
On-disk data
Over-the-wire data
Hardware registers
Binary interface specifications (that have explicitly sized objects or involve sharing or communication between 32–bit and 64–bit programs)
Binary data structures (that are used by 32–bit and 64–bit programs through shared memory, files, and so on)