新手主应用程序调用dll回调函数有关问题
新手求助:主应用程序调用dll回调函数问题
编译主程序时,老是报错:
cannot convert 'int (* (_closure )()()' to 'int(*)()'
type mismatch in parameter 1 (wanted 'int(*)()',got 'void')
请问各位大大,这到底是什么原因啊
------解决方案--------------------
aFunc((pt)&test1);
编译主程序时,老是报错:
cannot convert 'int (* (_closure )()()' to 'int(*)()'
type mismatch in parameter 1 (wanted 'int(*)()',got 'void')
请问各位大大,这到底是什么原因啊
- C/C++ code
//主应用程序 HINSTANCE ins; ins = LoadLibrary("./dll/dllTalk.dll"); try { if(ins == NULL) throw MyException("Can't Load Library!"); FARPROC lpFarProc; //回调函数未成功 lpFarProc = GetProcAddress(ins,"call"); if(lpFarProc == NULL) { FreeLibrary(ins); throw MyException("Can't Get dd Address!"); } typedef int (*pfv)(); typedef void (* pt)(pfv); pt aFunc = (pt)lpFarProc; aFunc(test1); //出错在这里 if(!FreeLibrary(ins)) { throw MyException("Can't Free!"); } } catch (MyException &myException) { ShowMessage(myException.test); } ……………… int test1() { return 0; } //dll程序 extern "C" __declspec(dllexport) void __stdcall call(int (*CallBack)()) { CallBack(); }
------解决方案--------------------
aFunc((pt)&test1);