I am developing a program for the Cortex-M3 STM32Fx series processor. The following values are defined in stdint.h:
typedef unsigned int uint_fast32_t;
typedef uint32_t uint_least32_t;
typedef unsigned long uint32_t;
As far as I understand.
[u]int_fast[n]_t will give you the fastest data type of at least n bits.
[u]int_least[n]_t will give you the smallest data type of at least n bits.
[u]int[n]_t will give you the data type of exactly n bits.
Also, as far as I know, sizeof (unsigned int) <= sizeof (unsigned long) and UINT_MAX <= ULONG_MAX - always.
Thus, I would expect uint_fast32_t to be a data type with a size equal to or greater than the size of uint32_t.
In the case of cortex-M3, sizeof (unsigned int) == sizeof (unsigned long) == 4. Thus, the above definitions are "correct" in terms of size.
But why are they not defined in a way that is consistent with the names and logical sizes of the underlying data types ie
typedef unsigned long uint_fast32_t;
typedef unsigned int uint_least32_t;
typedef uint_fast32_t uint32_t;
Can anyone clarify the choice of base types?
, "long" "int" , ?
typedef unsigned int uint_fast32_t;
typedef unsigned int uint_least32_t;
typedef unsigned int uint32_t;