Search code examples
ctypesstdint

Difference between C-Types int32_t int_least32_t etc


I have ever read that int32_t is exact 32 bits long and int_least32_t only at least 32 bits, but they have both the same typedefs in my stdint.h:

typedef int  int_least32_t;

and

typedef int  int32_t;

So where is the difference? They exactly the same...


Solution

  • int32_t is signed integer type with width of exactly 32 bits with no padding bits and using 2's complement for negative values. int_least32_t is smallest signed integer type with width of at least 32 bits. These are provided only if the implementation directly supports the type.

    The typedefs that you are seeing simply means that in your environment both these requirements are satisfied by the standard int type itself. This need not mean that these typedefs are the same on a different environment.