From decde99974f4d879329837d2f8ceb6a556895127 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 30 Oct 2022 20:49:41 +0000 Subject: Windows: Fix missing field initializers when building as C++ --- src/win.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/win.c') diff --git a/src/win.c b/src/win.c index 4b303eb..75915d7 100644 --- a/src/win.c +++ b/src/win.c @@ -35,6 +35,16 @@ #define PUGL_LOCAL_CLIENT_MSG (WM_USER + 52) #define PUGL_USER_TIMER_MIN 9470 +#ifdef __cplusplus +# define PUGL_INIT_STRUCT \ + {} +#else +# define PUGL_INIT_STRUCT \ + { \ + 0 \ + } +#endif + typedef BOOL(WINAPI* PFN_SetProcessDPIAware)(void); typedef HRESULT(WINAPI* PFN_GetProcessDpiAwareness)(HANDLE, DWORD*); typedef HRESULT(WINAPI* PFN_GetScaleFactorForMonitor)(HMONITOR, DWORD*); @@ -80,7 +90,7 @@ puglRegisterWindowClass(const char* name) module = GetModuleHandle(NULL); } - WNDCLASSEX wc = {0}; + WNDCLASSEX wc = PUGL_INIT_STRUCT; if (GetClassInfoEx(module, name, &wc)) { return true; // Already registered } @@ -472,8 +482,8 @@ initKeyEvent(PuglKeyEvent* event, } } else if (!dead) { // Translate unshifted key - BYTE keyboardState[256] = {0}; - wchar_t buf[5] = {0}; + BYTE keyboardState[256] = PUGL_INIT_STRUCT; + wchar_t buf[5] = PUGL_INIT_STRUCT; event->key = puglDecodeUTF16( buf, ToUnicode(vkey, vcode, keyboardState, buf, 4, 1 << 2)); @@ -689,7 +699,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) pt.y = GET_Y_LPARAM(lParam); if (!view->impl->mouseTracked) { - TRACKMOUSEEVENT tme = {0}; + TRACKMOUSEEVENT tme = PUGL_INIT_STRUCT; tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; -- cgit v1.2.1