C 类型之间的区别 int32_t int_least32_t 等 [英] Difference between C-Types int32_t int_least32_t etc
问题描述
我曾读过 int32_t 的长度正好是 32 位,而 int_least32_t 的长度至少为 32 位,但它们在我的 stdint.h 中有相同的 typedef:
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;
和
typedef int int32_t;
那么区别在哪里呢?他们完全一样...
So where is the difference? They exactly the same...
推荐答案
int32_t
是有符号整数类型,宽度为 32 位,没有填充位,负值使用 2 的补码.int_least32_t
是最小有符号整数类型,宽度至少为 32 位.仅当实现直接支持该类型时才提供这些.
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.
您看到的 typedef 只是意味着在您的环境中,标准 int
类型本身满足了这两个要求.这并不意味着这些 typedef 在不同的环境中是相同的.
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.
这篇关于C 类型之间的区别 int32_t int_least32_t 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!