While following some tutorials and reading about function pointers I learned that evidently assigning a void pointer to a function pointer in ISO C is undefined, is there any wa
No. The compiler is right, and you too: in C89 and C99, you can't convert between data pointers (which void *
is) and function pointers, so the only way for resolving the warning is returning a function pointer from the function.
(Note, however, that in practice this works despite the warning, and even there's this inconsistency in the standard library - the dlsym()
function is used for obtaining function pointers, but it returns void *
- so essentially you can ignore the warning. It will work, although strictly speaking the behavior is undefined here.)