I just noticed that this compiles without any errors or warnings using -pedantic -Wall with gcc and clang .
#include <stdio.h> int x = 0; void func(int f(const char *)) { f("func()!"); } int main(void) { func(puts); }
It seems that in this case the parameter f treated as a pointer to the int (*)(const char *) function.
But this is a behavior that I have never seen or heard of. Is this legal C code? And if so, what happens when you have a function as a parameter to a function?
source share