I've recently having problems with custm CALLBACK's function pointers, and that boiled down into using calling conventions which solve the problem temporaly, funy CALLBACK did work well then but signature of the calling function was still misstyped!! and I've spend a lot of time finding that BUG out. realized that caling convention let you do something what isn't OK sometimes...
OK that's past now... Now, I want to know a litle more about calling conventions:
Visual Studio has it's own __cdecl
, __thiscall
, etc (IIRC).
Does standard C++ regulates some calling conventions and how can I use them if so?
EDIT: Some code on which I failed to find a bug:
class Object;
class EventArgs;
typedef void(__cdecl Object::*MethodHandler)(Object* sender, EventArgs args);
///..... this is how I call it..(snapshot)
(iter->second.sender->*iter->second.memberFunct)(sender, args);
///...
void __cdecl Triger(EventArgs args) //missing "Object* sender" here!!! but it works!
{
if(args == "test")
cout << "test args received" << endl;
}
(BTW, type names are my custom classes.)
That worked just fine! Function was called but without __cdecl
I have received ESP register errors.