how to pass a non static-member function as a callback?
c++, callback, function, member, non-static
Solution
You could keep it static, but use the userdata to store the `this` pointer in addition to whatever other userdata you want (by packing them into a structure, for example) and then call an object-specific callback from the static version by calling `this->someCallback` (where `this` is the pointer stored in the userdata, of course).
Problem
``` io_iterator_t enumerator; kern_return_t result; result = IOServiceAddMatchingNotification( mNotifyPort, kIOMatchedNotification, IOServiceMatching( "IOFireWireLocalNode" ), serviceMatchingCallback, (void *)0x1234, & enumerator ); ``` ` ``` serviceMatchingCallback((void *)0x1234, enumerator); ``` ` if i declare serviceMatchinCallback as static then it works, but i do not want it to be static. Is there a way to pass it a non-static callback function? Thank you