how to pass a non static-member function as a callback?

后端 未结 8 613
深忆病人
深忆病人 2020-12-07 01:59

 
io_iterator_t enumerator;
kern_return_t   result;
result = IOServiceAddMatchingNotification(
             mNotifyPort,
             kIOMatchedNotification,
             


        
相关标签:
8条回答
  • 2020-12-07 02:36

    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).

    0 讨论(0)
  • 2020-12-07 02:38

    A non-static function has an implicit this parameter, and thus would have the wrong signature for the callback.

    Sorry, no easy way to avoid the jump island.

    0 讨论(0)
提交回复
热议问题