gpt4 book ai didi

c - sizeof(void*) != sizeof(uintptr_t) 在实践中?

转载 作者:太空宇宙 更新时间:2023-11-04 02:30:13 24 4
gpt4 key购买 nike

虽然 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 嵌入式微 Controller )。 1990 年代的 Cray 是个异常(exception)(但它是 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 的有用程序非常少见)

关于c - sizeof(void*) != sizeof(uintptr_t) 在实践中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44357802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com