sizeof(void*) 和 sizeof(function_type_ptr*) 相等

发布于 2024-08-20 12:09:14 字数 228 浏览 5 评论 0原文

sizeof(void*) 和 sizeof(function_type_ptr*) 相等

sizeof(void*) 和 sizeof(function_type_ptr*) 必须相等吗? C(C90、C99)标准是否要求?

function_type_ptr 是指向函数的指针。

这个问题是关于标准要求,而不是您自己的意见。请提供标准的链接、章节号和引文

sizeof(void*) and sizeof(function_type_ptr*) equality

Must sizeof(void*) and sizeof(function_type_ptr*) be equal? Is it required by C (C90, C99) standard?

function_type_ptr is pointer to function.

This question is about standard requirements, not your own opinion. Please, give links, section numbers and quotations from standards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放低过去 2024-08-27 12:09:14

答案是否定的。

6.2.6.1/2:除了位域之外,对象由一个或多个字节的连续序列组成,其数量、顺序和编码要么是显式指定的,要么是实现定义的。

函数/空指针没有这样的规范。

The answer is no.

6.2.6.1/2: Except for bit-fields, objects are composed of contiguous sequences of one or more bytes, the number, order, and encoding of which are either explicitly specified or implementation-defined.

No such specification is done for function / void pointers.

百思不得你姐 2024-08-27 12:09:14

根据这篇文章答案是否定的,没有保证即使 sizeof(int*) 也与 sizeof(double*) 相同。

According to this post the answer is no, there is no guarantee that even sizeof(int*) is the same as sizeof(double*).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文