为什么在C(和C ++)标准中uintptr_t和intptr_t可选类型? [英] Why are uintptr_t and intptr_t optional types in the C (and C++) standard?
问题描述
对于C99(及更高版本的标准),标头< stdint.h>
中要求某些类型可用。对于精确宽度,例如 int8_t
, int16_t
等,它们是可选的,并且是标准格式
With C99 (and later standards) standard requires certain types to be available in the header <stdint.h>
. For exact-width, e.g., int8_t
, int16_t
, etc..., they are optional and motivated in the standard why that is.
但是对于 uintptr_t
和 intptr_t
类型,也是可选的,但我看不出它们是可选而不是必需的原因。
But for the uintptr_t
and intptr_t
type, they are also optional but I don't see a reason for them being optional instead of required.
推荐答案
在某些平台上,指针类型具有比任何整数类型都大得多的尺寸。我相信这样的平台示例将是IBM AS / 400,其虚拟指令集将所有指针定义为128位。这种平台的最新示例是Elbrus。它使用128位指针,它们是硬件描述符,而不是普通地址。
On some platforms pointer types have much larger size than any integral type. I believe an example of such as platform would be IBM AS/400 with virtual instruction set defining all pointers as 128-bit. A more recent example of such platform would be Elbrus. It uses 128-bit pointers which are HW descriptors rather than normal addresses.
这篇关于为什么在C(和C ++)标准中uintptr_t和intptr_t可选类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!