How can I pass a dynamic generated C++ function as *funcprt to a C API?
The API exports this:
DllImport void api_register_func(char *func_name, void (*funcptr)(char *, char *));
I have to create the function while runtime because I don't know about it before. So I used a class:
class JsFunc
{
public:
char * JsFuncName;
char * JsParameter;
void RunFunc(char * val1, char * val2)
{
printf("\nJsFunc.runFunc executed, JsParameter=%s passed\n",JsParameter);
}
};
And call it like this:
JsFunc * jsm = new JsFunc ();
jsm->JsFuncName = external_parameter1;
jsm->JsParameter = external_parameter2;
api_register_func(external_parameter1, jsm->RunFunc);
But VisualStudio 2015 tells me:
Error C3867 'JsFunc::runFunc': non-standard syntax; use '&' to create a pointer to member VJCS C:\Users\astrauss\Source\Repos\VCJS\VCJS\VCJS.cpp 54
Sorry if the code is bad, I'm not a C/C++ programmer but need to get this running for my daily work. Thanks!