Callback functions
-
hi All, I have a class with functions and I'm calling into a dll with a function that specifies a callback function Here's the function I'm calling: extern "C" __declspec(dllexport) void stuffFunction(void (*UpdateCallback)(int iLoad)) And here's the class function I'm trying to pass in as a call back: void CSomeClass::UpdateCallback(int iLoad); I get the error: error C2664: 'someapp.c' : cannot convert parameter 1 from 'void (int)' to 'void (__cdecl *)(int)' If I declare the UpdateCallback to be a static function, it builds with no errors. I need to have access to the class members so I can't declare it as a static function. Any ideas? Thanks in advance!
-
hi All, I have a class with functions and I'm calling into a dll with a function that specifies a callback function Here's the function I'm calling: extern "C" __declspec(dllexport) void stuffFunction(void (*UpdateCallback)(int iLoad)) And here's the class function I'm trying to pass in as a call back: void CSomeClass::UpdateCallback(int iLoad); I get the error: error C2664: 'someapp.c' : cannot convert parameter 1 from 'void (int)' to 'void (__cdecl *)(int)' If I declare the UpdateCallback to be a static function, it builds with no errors. I need to have access to the class members so I can't declare it as a static function. Any ideas? Thanks in advance!
What you are doing is illegal. You can't use a method as you do. You'll need to make it static. Non-static methods can only be accesed by an instance of the class. So, you need to make it static. Rickard Andersson8 Here is my card, contact me later! UIN: 50302279 E-Mail: nikado@pc.nu Interests: C++, ADO, SQL, Winsock, 0s and 1s
-
What you are doing is illegal. You can't use a method as you do. You'll need to make it static. Non-static methods can only be accesed by an instance of the class. So, you need to make it static. Rickard Andersson8 Here is my card, contact me later! UIN: 50302279 E-Mail: nikado@pc.nu Interests: C++, ADO, SQL, Winsock, 0s and 1s
-
That's what I thought :( I just wanted to be sure there were no other tricks out there I didn't know about. Thanks.. .... Just gotta do it another way =)
will1383 wrote: I just wanted to be sure there were no other tricks out there I didn't know about. Yeah! It's better being on the safe side! :) Rickard Andersson8 Here is my card, contact me later! UIN: 50302279 E-Mail: nikado@pc.nu Interests: C++, ADO, SQL, Winsock, 0s and 1s