In C you can cast a pointer, okay anything really, to a function pointer and then call it.
int foo(int a, int b){return a+b; }
void *vptr = foo;
int (*yolo)(int a) = vptr;
int c = yolo(10); // Cthulhu come
This sort of thing can happen when you pass a function pointer into some sort of callback mechanism+. When you get it back you have to cast it to the right type and then call it. So there is a disconnect between the cast and the function definition, unless you tie both together with a typedef.+ Often helpful for an api that takes a callback to also record, who the caller was and some arbitrary bit of data. The arbitary bit of data might be a function pointer.
This is however a very common extension allowed in most compilers, since most processors that people encounter keep code and data in the same memory address pool. But on DSPs, it's common for data and code memory to be distinct address spaces, and the two pointer types aren't necessarily the same size.
Later, when I want to call the original function, I assign to a properly typed variable to the value of the void
original_function member. The compiler has no way to know if that void * is actually FILE (fopen )(char , char ) or if it's int(open )(char , int, ...).When everything can be properly typed, I only ever get warnings about assigning the wrong function types to the wrong function pointer variables.
If you try to cast a pointer into your function type, you'll get a runtime error, not a compile time one.