C and C++ developers often forget that the size of fundamental data types such as char, short, and int are architecture-dependent. At the same time, most of the hardware peripherals define specific requirements regarding the size of the fields that are used for data exchanges. To make the code working with the external hardware or communication protocols portable, embedded developers use fixed-size integer types, which explicitly specify the size of a data field.
Some of the most commonly used data types are as follows:
Width | Signed | Unsigned |
8-bit | int8_t | uint8_t |
16-bit | int16_t | uint16_t |
32-bit | int32_t | uint32_t |
The pointer size also depends on the architecture. Developers often need to address the elements of arrays, and since arrays are internally represented as pointers, the offset representation depends on the pointer...