# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1593885106 0 # Node ID 42f8ad7a89e83643d4abf1f536e198ac1fcb196a # Parent fc29c4c2d38667c703bbc389e26772307e6326e5 Added DW_POINTER_TO_(U)LONGLONG and DW_(U)LONGLONG_TO_POINTER macros. This allows casting with intermediate (u)intptr_t cast to avoid compiler warnings on different systems. Use these macros where necessary in the code. Might need to check the compiler supports LONG LONG... since some compilers we support might not, like old versions of VisualAge C and Watcom. diff -r fc29c4c2d386 -r 42f8ad7a89e8 dw.h --- a/dw.h Tue Jun 30 20:10:23 2020 +0000 +++ b/dw.h Sat Jul 04 17:51:46 2020 +0000 @@ -1512,6 +1512,10 @@ #define DW_POINTER_TO_INT(a) ((int)(intptr_t)a) #define DW_UINT_TO_POINTER(a) ((void *)(uintptr_t)a) #define DW_POINTER_TO_UINT(a) ((unsigned int)(uintptr_t)a) +#define DW_LONGLONG_TO_POINTER(a) ((void *)(intptr_t)a) +#define DW_POINTER_TO_LONGLONG(a) ((long long)(intptr_t)a) +#define DW_ULONGLONG_TO_POINTER(a) ((void *)(uintptr_t)a) +#define DW_POINTER_TO_ULONGLONG(a) ((unsigned long long)(uintptr_t)a) #elif ULONG_MAX > UINT_MAX /* If no intptr_t... ULONG is often bigger than UINT */ #define DW_INT_TO_POINTER(a) ((void *)(long)a) @@ -1525,6 +1529,12 @@ #define DW_UINT_TO_POINTER(a) ((void *)a) #define DW_POINTER_TO_UINT(a) ((unsigned int)a) #endif +#ifndef DW_LONGLONG_TO_POINTER +#define DW_LONGLONG_TO_POINTER(a) ((void *)a) +#define DW_POINTER_TO_LONGLONG(a) ((long long)a) +#define DW_ULONGLONG_TO_POINTER(a) ((void *)a) +#define DW_POINTER_TO_ULONGLONG(a) ((unsigned long long)a) +#endif #define DW_POINTER(a) ((void *)a) #ifndef DW_FCF_COMPOSITED diff -r fc29c4c2d386 -r 42f8ad7a89e8 gtk/dw.c --- a/gtk/dw.c Tue Jun 30 20:10:23 2020 +0000 +++ b/gtk/dw.c Sat Jul 04 17:51:46 2020 +0000 @@ -1988,10 +1988,10 @@ int (*func)(HWND, void *); void *data; - snprintf(textbuf, 100, "dw-notification-%llu-func", (unsigned long long)g_variant_get_uint64(param)); + snprintf(textbuf, 100, "dw-notification-%llu-func", DW_POINTER_TO_ULONGLONG(g_variant_get_uint64(param))); func = g_object_get_data(G_OBJECT(_DWApp), textbuf); g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL); - snprintf(textbuf, 100, "dw-notification-%llu-data", (unsigned long long)g_variant_get_uint64(param)); + snprintf(textbuf, 100, "dw-notification-%llu-data", DW_POINTER_TO_ULONGLONG(g_variant_get_uint64(param))); data = g_object_get_data(G_OBJECT(_DWApp), textbuf); g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL); @@ -12423,7 +12423,7 @@ /* Generate a unique ID based on the notification handle, * so we can use it to remove the notification in dw_window_destroy(). */ - snprintf(id, 100, "dw-notification-%llu", (unsigned long long)notification); + snprintf(id, 100, "dw-notification-%llu", DW_POINTER_TO_ULONGLONG(notification)); g_application_send_notification(_DWApp, id, (GNotification *)notification); return DW_ERROR_NONE; } @@ -13537,9 +13537,9 @@ if (G_IS_NOTIFICATION(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) { char textbuf[101] = {0}; - snprintf(textbuf, 100, "dw-notification-%llu-func", (unsigned long long)thiswindow); + snprintf(textbuf, 100, "dw-notification-%llu-func", DW_POINTER_TO_ULONGLONG(thiswindow)); g_object_set_data(G_OBJECT(_DWApp), textbuf, DW_POINTER(sigfunc)); - snprintf(textbuf, 100, "dw-notification-%llu-data", (unsigned long long)thiswindow); + snprintf(textbuf, 100, "dw-notification-%llu-data", DW_POINTER_TO_ULONGLONG(thiswindow)); g_object_set_data(G_OBJECT(_DWApp), textbuf, DW_POINTER(data)); DW_MUTEX_UNLOCK; return; diff -r fc29c4c2d386 -r 42f8ad7a89e8 gtk3/dw.c --- a/gtk3/dw.c Tue Jun 30 20:10:23 2020 +0000 +++ b/gtk3/dw.c Sat Jul 04 17:51:46 2020 +0000 @@ -1963,10 +1963,10 @@ int (*func)(HWND, void *); void *data; - snprintf(textbuf, 100, "dw-notification-%llu-func", (unsigned long long)g_variant_get_uint64(param)); + snprintf(textbuf, 100, "dw-notification-%llu-func", DW_POINTER_TO_ULONGLONG(g_variant_get_uint64(param))); func = g_object_get_data(G_OBJECT(_DWApp), textbuf); g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL); - snprintf(textbuf, 100, "dw-notification-%llu-data", (unsigned long long)g_variant_get_uint64(param)); + snprintf(textbuf, 100, "dw-notification-%llu-data", DW_POINTER_TO_ULONGLONG(g_variant_get_uint64(param))); data = g_object_get_data(G_OBJECT(_DWApp), textbuf); g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL); @@ -11128,7 +11128,7 @@ /* Generate a unique ID based on the notification handle, * so we can use it to remove the notification in dw_window_destroy(). */ - snprintf(id, 100, "dw-notification-%llu", (unsigned long long)notification); + snprintf(id, 100, "dw-notification-%llu", DW_POINTER_TO_ULONGLONG(notification)); g_application_send_notification(_DWApp, id, (GNotification *)notification); return DW_ERROR_NONE; } @@ -12064,9 +12064,9 @@ if (G_IS_NOTIFICATION(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) { char textbuf[101] = {0}; - snprintf(textbuf, 100, "dw-notification-%llu-func", (unsigned long long)thiswindow); + snprintf(textbuf, 100, "dw-notification-%llu-func", DW_POINTER_TO_ULONGLONG(thiswindow)); g_object_set_data(G_OBJECT(_DWApp), textbuf, DW_POINTER(sigfunc)); - snprintf(textbuf, 100, "dw-notification-%llu-data", (unsigned long long)thiswindow); + snprintf(textbuf, 100, "dw-notification-%llu-data", DW_POINTER_TO_ULONGLONG(thiswindow)); g_object_set_data(G_OBJECT(_DWApp), textbuf, DW_POINTER(data)); DW_MUTEX_UNLOCK; return; diff -r fc29c4c2d386 -r 42f8ad7a89e8 mac/dw.m --- a/mac/dw.m Tue Jun 30 20:10:23 2020 +0000 +++ b/mac/dw.m Sat Jul 04 17:51:46 2020 +0000 @@ -10900,7 +10900,7 @@ #ifdef BUILDING_FOR_MOUNTAIN_LION if(notification) { - NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", (unsigned long long)notification]; + NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", DW_POINTER_TO_ULONGLONG(notification)]; #ifdef BUILDING_FOR_MOJAVE // Schedule the notification.