sizeof(void*) != sizeof(uintptr_t) 在实践中?
sizeof(void*) != sizeof(uintptr_t) in practice?
虽然 C99 标准理论上允许 sizeof(void*) != sizeof(uintptr_t)
(至少据我所知),但是否存在宽度不同的现代系统?也就是说,作为一个实际问题,依赖于这些类型具有相同宽度的假设是否合理?
the C99 standard theoretically allows for sizeof(void*) != sizeof(uintptr_t)
are there any modern systems where the widths are different?
我现在还不知道这样的系统(但也许您会发现一些奇怪的 VLIW 嵌入式微控制器)。 1990年代的Cray是个例外(不过是C89,不是C99)
i.e., as a practical matter, would it be reasonable to rely on the assumption that these types have the same width?
当然是实践。顺便说一句,通常您的源代码实际上会有其他依赖项(例如,通常使用一些非 C99 标准函数,但通常可用的函数,例如 POSIX)。
(实际上,不依赖于外部库的严格符合C99的有用程序非常少见)
虽然 C99 标准理论上允许 sizeof(void*) != sizeof(uintptr_t)
(至少据我所知),但是否存在宽度不同的现代系统?也就是说,作为一个实际问题,依赖于这些类型具有相同宽度的假设是否合理?
the C99 standard theoretically allows for
sizeof(void*) != sizeof(uintptr_t)
are there any modern systems where the widths are different?
我现在还不知道这样的系统(但也许您会发现一些奇怪的 VLIW 嵌入式微控制器)。 1990年代的Cray是个例外(不过是C89,不是C99)
i.e., as a practical matter, would it be reasonable to rely on the assumption that these types have the same width?
当然是实践。顺便说一句,通常您的源代码实际上会有其他依赖项(例如,通常使用一些非 C99 标准函数,但通常可用的函数,例如 POSIX)。
(实际上,不依赖于外部库的严格符合C99的有用程序非常少见)