sizeof(void*) 和 sizeof(function_type_ptr*) 相等
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是否定的。
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.
根据这篇文章答案是否定的,没有保证即使
sizeof(int*)
也与sizeof(double*)
相同。According to this post the answer is no, there is no guarantee that even
sizeof(int*)
is the same assizeof(double*)
.