为什么在C函数总是1个字节的大小? [英] Why is the size of a function in C always 1 byte?

查看:167
本文介绍了为什么在C函数总是1个字节的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们检查函数的使用 sizeof的大小(),我们总能得到的 1个字节
这是什么1个字节表示?

When we check the size of a function using sizeof(), we always get 1 byte. What does this 1 byte signify?

推荐答案

这是一个约束冲突,你的编译器的的诊断它。如果它编译它尽管如此,你的程序未定义的行为[感谢@Steve杰索普的澄清失效模式,并看到从C11,6.5.3.4./1:

It's a constraint violation, and your compiler should diagnose it. If it compiles it in spite of that, your program has undefined behaviour [thanks to @Steve Jessop for the clarification of the failure mode, and see @Michael Burr's answer for why some compilers allow this]: From C11, 6.5.3.4./1:

的sizeof 经营者不得被应用到具有函数型的前pression

The sizeof operator shall not be applied to an expression that has function type

这篇关于为什么在C函数总是1个字节的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆