Reputation: 7947
I am converting a program from C to C++. I have the compiler set to use the __fastcall calling convention by default.
I used to have a declaration line as follows:
INT32 PASCAL graph_window_handler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Later I have:
wndclass.lpfnWndProc = graph_window_handler;
This all compiled and worked under C. But under C++ I get all sorts of complaints form the compiler about the second line of code. I guess I need to change the original declaration to something involving WNDPROC, perhaps with a _cdecl thrown in? With or without the INT32? but it seems that every variation I try still gets complained about. What should the declaration look like such that the second line does not get complained about? - cheers.
Upvotes: 1
Views: 1288
Reputation: 99625
According to MSDN documentation it should look like the following:
LRESULT CALLBACK graph_window_handler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
And if you'll check WinUser.h
you'll see that WNDPROC
typedef'ed as follows:
typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
Upvotes: 5