In the following program, withExcellent. You're on the right newsgroup. According
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-56)
there is no error. I have two queries.
to the founding message of this group, compiler-specific
discussion is on-topic here.
1. isn't it illegal to apply sizeof on function type.When Microsoft disregards the standards, it's an abomination.
6.5.3.4 The sizeof operator
The sizeof operator shall not be applied to an expression that has
function type....
in fact VS 2005 gives error on this.
When Microsoft adheres to the standards, it's a restriction.
2. If compiler is taking f as a pointer and not as function name,The why of it is that gcc has an extension for pointer arithmetic
which is legal to do though i am not sure if it is advisable to do so
here in this case, then why the sizeof f is "1" and not 4 as for
sizeof g
on void pointers and function pointers. If you think about it, the
most appropriate value for sizeof(void) and sizeof(f) would be 1.
The how of it is obscured by the fact that gcc internals change
like Madonna's sleeping partners. For some advice that should be
stable across gcc versions, check out the function
c_sizeof_or_alignof_type() in c-common.c for a type_code
of FUNCTION_TYPE and have tree.c/tree.h at hand. You'll see that
f isn't treated as a function pointer and that there's no magical
size calculation involved that cares about the definition of f.
Yours,
Han from China