“sizeof(函数名)"返回什么? [英] What does 'sizeof (function name)' return?
本文介绍了“sizeof(函数名)"返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例代码:
int main(void)
{
printf ("size = %d
", sizeof(main));
}
返回值 sizeof
应用于函数名是什么,例如 main
?
What is the returned value sizeof
applied to a function name, for example main
?
推荐答案
C 标准禁止它 - 当使用 gcc -pedantic
编译时,它会产生 'sizeof' 对函数的无效应用输入
警告.
C standard forbids it - when compiled with gcc -pedantic
, it produces invalid application of ‘sizeof’ to a function type
warning.
但是gcc
编译它并返回1
for sizeof(main)
,它不是函数指针的大小.
However gcc
compiles it and returns 1
for sizeof(main)
, and it is not a size of function pointer.
它似乎依赖于编译器.
这篇关于“sizeof(函数名)"返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文