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