Pass function pointer from C++ to objective-c -
i'm trying pass function pointer c++ class objective-c class. want store function pointer in class variable of objective-c class , use callback function c++ class.
i've bridged few calls c++ objective-c passing void pointers objects, when comes passing function pointer, can't manage it.
i have c++ class (.h , .cpp files), interface (.h file) , objective-c class (.h , .mm files):
c++ header:
class cppclass { void showaboutwnd(){}//does nothing getobjc(); }
c++ .cpp:
#include "cppclass.h" #include "bridgeheader.h" void* objc; void cppclass::getobjc { objc = getobjinstance();//gets objective-c object use further showui(objc); void (cppclass::*functptr)() = null; functptr = &cppclass::showaboutwnd; setshowaboutptr(objc, functptr); //the last call generates semantic error: no matching function call 'setshowaboutptr' }
the bridge header:
int showui(void *objc); void setshowaboutptr(void *objc, void (*functptr)());
the objective-c implement file (.mm):
@implementation classobjectivec // c trampoline function invoke objective-c method int showui (void *self) { return [(id)self dooverrides];//calls method customise nsview } void setshowaboutptr (void *self, void (*f)()) { // nothing atm }
i semantic error when try call setshowaboutptr(objc, functptr);
.cpp file: no matching function call 'setshowaboutptr'
.
Comments
Post a Comment