I\'m currently using GCC 4.4, and I\'m having quite the headache casting between void*
and a pointer to member function. I\'m trying to write an easy-to-use li
Unlike the address of a nonstatic member function, which is a pointer-to-member type with a complicated representation, the address of a static member function is usually a just a machine address, compatible with a conversion to void *
.
If you need to bind a C++ non-static member function to a C or C-like callback mechanism based on void *
, what you can try to do is write a static wrapper instead.
The wrapper can take a pointer to an instance as an argument, and pass control to the nonstatic member function:
void myclass::static_fun(myclass *instance, int arg)
{
instance->nonstatic_fun(arg);
}