From 190ea6ed1006959a6cfab405b932aa89fb9b461a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Thu, 20 Sep 2018 05:18:51 +0000 Subject: [PATCH] tests W32: Fix Windows values casting LPARAM is LONG_PTR which is the same as INT_PTR on Windows. WPARAM is UINT_PTR. HWND is a pointer. (%p prints pointers without 0x prefix, hence the extra 0x). --- tests/gio-test.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/gio-test.c b/tests/gio-test.c index c9523fba2..d9bd7e357 100644 --- a/tests/gio-test.c +++ b/tests/gio-test.c @@ -214,7 +214,7 @@ recv_windows_message (GIOChannel *channel, { GIOError error; MSG msg; - guint nb; + gsize nb; while (1) { @@ -232,20 +232,25 @@ recv_windows_message (GIOChannel *channel, break; } - g_print ("gio-test: ...Windows message for %#x: %d,%d,%d\n", - msg.hwnd, msg.message, msg.wParam, msg.lParam); + g_print ("gio-test: ...Windows message for 0x%p: %d,%" G_GUINTPTR_FORMAT ",%" G_GINTPTR_FORMAT "\n", + msg.hwnd, msg.message, msg.wParam, (gintptr)msg.lParam); return TRUE; } +LRESULT CALLBACK window_procedure (HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam); + LRESULT CALLBACK window_procedure (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { - g_print ("gio-test: window_procedure for %#x: %d,%d,%d\n", - hwnd, message, wparam, lparam); + g_print ("gio-test: window_procedure for 0x%p: %d,%" G_GUINTPTR_FORMAT ",%" G_GINTPTR_FORMAT "\n", + hwnd, message, wparam, (gintptr)lparam); return DefWindowProc (hwnd, message, wparam, lparam); } @@ -331,7 +336,7 @@ main (int argc, nrunning++; #ifdef G_OS_WIN32 - cmdline = g_strdup_printf ("%d:%d:%d", + cmdline = g_strdup_printf ("%d:%d:0x%p", pipe_to_sub[0], pipe_from_sub[1], hwnd); @@ -388,7 +393,7 @@ main (int argc, sscanf (argv[2], "%d:%d%n", &readfd, &writefd, &n); #ifdef G_OS_WIN32 - sscanf (argv[2] + n, ":%d", &hwnd); + sscanf (argv[2] + n, ":0x%p", &hwnd); #endif srand (tv.tv_sec ^ (tv.tv_usec / 1000) ^ readfd ^ (writefd << 4)); @@ -413,8 +418,8 @@ main (int argc, int msg = WM_USER + (rand() % 100); WPARAM wparam = rand (); LPARAM lparam = rand (); - g_print ("gio-test: child posting message %d,%d,%d to %#x\n", - msg, wparam, lparam, hwnd); + g_print ("gio-test: child posting message %d,%" G_GUINTPTR_FORMAT ",%" G_GINTPTR_FORMAT " to 0x%p\n", + msg, wparam, (gintptr)lparam, hwnd); PostMessage (hwnd, msg, wparam, lparam); } #endif