Considering this code with 3 differents function call semantics:
void f(void){
puts("OK");
}
int main(void){
f();
(*f)();
(&f)();
return 0;
}
The first is the standard way to call f,
the second is the semantic for dereferencing function pointers,
but in the third I’m applying the & operator to the function name and it seems to work fine.
What does in the second and third case happen?
Thanks.
Function calls are always performed via function pointers. From C99 section 6.5.2.2:
However, in almost all cases a function type decays to a function-pointer type. From C99 section 6.3.2.1:
So your three calls are evaluated thus:
All are valid. But obviously, the first one (
f()) is the cleanest and easiest to read.