Search code examples
cc-standard-librarystdint

C standard difference between int_least32_t and long


I was wondering, what is the difference between int_least32_t and long, since according to the standard, long has to be at least 32 bits wide and int_least32_t should, according to the standard, also be at least 32 bits wide, therefore equivalent in definition to long. That brings me to the question, what is the difference between them (if we are considering the case of an implementation which is also equipped with C standard library)?

Sources - https://en.wikipedia.org/wiki/C_data_types#Main_types, https://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types.


Solution

  • long must be at least 32 bits wide, but it is allowed to be larger even if a 32 bit type exists on the architecture.

    int_least32_t must be 32 bits wide if such a type exists on the architecture, and can only be larger if that's impossible on a given architecture (and must then be the next smallest size available).