Skip to content

Commit

Permalink
Fix compilation under certain circumstances (KDAB#5)
Browse files Browse the repository at this point in the history
Functions passed as WNDPROC need to have their calling convention
defined via CALLBACK define. Normally CALLBACK expands to __stdcall and
by default functions are __cdecl which is a mismatch.

Not sure why it worked before.

Change-Id: I1bffcb7b9b4342375c5db631729a8deae357569f
  • Loading branch information
MiKom committed Feb 1, 2024
1 parent e9391f3 commit 13407b2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum {
WM_KD_SOCKETEVENT = WM_USER,
};

LRESULT Win32PlatformEventLoop::messageWindowProc(HWND hwnd, UINT msgId, WPARAM wp, LPARAM lp)
LRESULT CALLBACK Win32PlatformEventLoop::messageWindowProc(HWND hwnd, UINT msgId, WPARAM wp, LPARAM lp)
{
auto *loop = reinterpret_cast<Win32PlatformEventLoop *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class KDFOUNDATION_API Win32PlatformEventLoop : public AbstractPlatformEventLoop
};
std::unordered_map<int, NotifierSet> m_notifiers;

static LRESULT messageWindowProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK messageWindowProc(HWND, UINT, WPARAM, LPARAM);
void handleSocketMessage(WPARAM wParam, LPARAM lParam);
bool registerWithWSAAsyncSelect(int fd, const NotifierSet &notifiers) const;

Expand Down
2 changes: 1 addition & 1 deletion src/KDGui/platform/win32/win32_platform_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ KeyboardModifiers getKeyboardModifiers()
return modifiers;
}

LRESULT windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
auto *platformWindow = reinterpret_cast<Win32PlatformWindow *>(GetProp(hwnd, KDGuiPlatformWindowProperty));
if (!platformWindow)
Expand Down

0 comments on commit 13407b2

Please sign in to comment.