int foo(char *c) {...}
main() {
int (*thud)(void *);
thud = (int (*)(void *))(foo);
}
What actually happens during the evaluation of the assignment?
There is a difference between the cast type and foo
; the cast type is a pointer and foo
is a function. So, does the compiler convert what's in '(foo)
' into a pointer to foo
and only then make the cast? Because nothing else seems to make sense; the other option is that the function itself is converted to a pointer to a function that gets a void*
and returns an int
, and as far as I know a function is a label to a piece of code in memory and thus cannot become a pointer, which is a variable.