You cannot cast a function pointer to void*
with static_cast
, but you may be able to do so with reinterpret_cast
.
This is conditionally-supported with implementation-defined semantics, except that casting back to the original function pointer type yields the same pointer value, so that it may be used again to call the function.
Probably you aren't allowed to do anything else with the void*
obtained in such a way, but you will need to look at the compiler documentation to determine that. (Compilers should document implementation-defined behavior, but it often isn't done well or at all.)
Especially on POSIX systems and Windows this cast is always supported.