No!
int f(char x, float y);
int g(char x, float y);
typedef int(*FunctPtr)(char,float);
int callit(FunctPtr p, char x, float y)
{
return p(x, y);
}
int main()
{
FunctPtr p = f;
void* p2 = (void*)p; // ← illegal!!
callit(p, 'x', 3.14f); // okay
callit(FunctPtr(p2), 'x', 3.14f); // might fail!!
...
}
Technical details:
void* pointers are pointers to data, and function
pointers point to functions. The language does not require functions and data
to be in the same address space, so, by way of
example and
not
limitation, on architectures that have them in different address spaces,
the two different pointer types will not be comparable.
Please do not email me if the above seems to work on your
particular version of your particular compiler on your particular operating
system. I don't care. It's illegal, period.