Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason "&amp;MyFrameGrabber::HookFunction" cannot be converted to a BUF_HOOK_FUNCTION_PTR is that, being a member of the class, it has implicitly as first parameter the "this" pointer, thus you cannot convert a member function to a non-member function: the two signatures look the same but are actually different.</p> <p>I would declare an interface, defining the function to call, have your class implement it and pass the object itself instead of the callback (you can think of an interface as the object-oriented replacement of a function pointer):</p> <pre><code>class IHookInterface{ public: virtual long HookFunction(long, long, void*) = 0; }; class HookClass : public IHookInterface{ public: virtual long Hook(long, long, void*) { // your code here... } }; </code></pre> <p>// new definition: ThirdPartyGrab (..., IHookInterface, ...);</p> <p>EDIT - other possible solution in case you cannot modify the library: use a singleton rather than a static function.</p> <pre><code>class HookClass{ public: static HookClass&amp; instance(){ static HookClass _instance; return _instance; } long Hook(long, long, void*) { // your code here... } }; long call_hook(long x,long y,void * z){ return HookClass::instance().Hook(x,y,z); } </code></pre> <p>SECOND EDIT: you might slightly modify the singleton class with an initialization method to call the constructor with the proper parameters, but maybe it is not more elegant than the following solution, which is simpler:</p> <pre><code>class HookClass{ public: HookClass(string x,string y...){ } long Hook(long, long, void*) { // your code here... } }; static HookClass * hook_instance = 0; long call_hook(long x,long y,void * z){ if (0 != hook_instance){ return hook_instance-&gt;Hook(x,y,z); } } int main(){ hook_instance = new HookClass("x","y"); ThirdPartyGrab(..., call_hook, ...); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload