Sample code:
int main(void)
{
printf ("size = %d\n", sizeof(main));
}
What is the returned value sizeof
applied to a function name, for example main
?
C standard forbids it - when compiled with gcc -pedantic
, it produces invalid application of ‘sizeof’ to a function type
warning.
However gcc
compiles it and returns 1
for sizeof(main)
, and it is not a size of function pointer.
It seems to be compiler-dependent.