changeset 2159:48172881415c

GTK: Add DW_UNUSED() macro for defining variables that may be unused. Move the compiler macro section to the top of dw.h for use all over. Use DW_UNUSED() to avoid several expected warnings in the GTK code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 29 Sep 2020 04:06:20 +0000
parents df3ee6273557
children 07f1366a724c
files dw.h gtk/dw.c gtk3/dw.c
diffstat 3 files changed, 41 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Mon Sep 28 20:27:11 2020 +0000
+++ b/dw.h	Tue Sep 29 04:06:20 2020 +0000
@@ -14,6 +14,44 @@
 
 #define DW_HOME_URL "http://dwindows.netlabs.org"
 
+/* Support for API deprecation in supported compilers */
+#if defined(__has_feature) && !defined(__has_extension)
+#define __has_extension __has_feature
+#endif
+
+/* Visual C */
+#if defined(_MSC_VER)
+#  if _MSC_VER >= 1400
+#  define DW_DEPRECATED(func, message) __declspec(deprecated(message)) func
+#  endif
+/* Clang */
+#elif defined(__clang__) && defined(__has_extension)
+#  if __has_extension(attribute_deprecated_with_message)
+#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated (message)))
+#  else
+#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated))
+#  endif
+/* GCC */
+#elif defined(__GNUC__)
+#  if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500
+#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated (message)))
+#  else
+#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated))
+#  endif
+#endif
+
+/* Compiler without deprecation support */
+#ifndef DW_DEPRECATED
+#define DW_DEPRECATED(func, message) func
+#endif
+
+/* Support for unused variables in supported compilers */
+#if defined(__GNUC__) || (defined(__clang__) && defined(__has_extension))
+#define DW_UNUSED(x) x __attribute__((__unused__))
+#else
+#define DW_UNUSED(x) x
+#endif
+
 #if !defined(__PHOTON__)
 /* These corespond to the entries in the color
  * arrays in the Win32 dw.c, they are also the
@@ -1302,7 +1340,7 @@
 } DWResources;
 
 #if !defined(DW_RESOURCES) || defined(BUILD_DLL)
-static DWResources _resources = { 0, 0, 0 };
+static DWResources DW_UNUSED(_resources) = { 0, 0, 0 };
 #else
 extern DWResources _resources;
 #endif
@@ -1575,37 +1613,6 @@
 /* Use the dbsoft.org application domain by default if not specified */
 #define DW_APP_DOMAIN_DEFAULT "org.dbsoft.dwindows"
 
-/* Support for API deprecation in supported compilers */
-#if defined(__has_feature) && !defined(__has_extension)
-#define __has_extension __has_feature
-#endif
-
-/* Visual C */
-#if defined(_MSC_VER)
-#  if _MSC_VER >= 1400
-#  define DW_DEPRECATED(func, message) __declspec(deprecated(message)) func
-#  endif
-/* Clang */
-#elif defined(__has_extension)
-#  if __has_extension(attribute_deprecated_with_message)
-#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated (message)))
-#  else
-#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated))
-#  endif
-/* GCC */
-#elif defined(__GNUC__)
-#  if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500
-#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated (message)))
-#  else
-#  define DW_DEPRECATED(func, message) func __attribute__ ((deprecated))
-#  endif
-#endif
-
-/* Compiler without deprecation support */
-#ifndef DW_DEPRECATED
-#define DW_DEPRECATED(func, message) func
-#endif
-
 /* Public function prototypes */
 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad);
 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad);
--- a/gtk/dw.c	Mon Sep 28 20:27:11 2020 +0000
+++ b/gtk/dw.c	Tue Sep 29 04:06:20 2020 +0000
@@ -9737,7 +9737,7 @@
    {
       FD_ZERO(&rd);
       FD_SET(listenfd, &rd);
-      int result;
+      int DW_UNUSED(result);
 
       maxfd = listenfd;
 
--- a/gtk3/dw.c	Mon Sep 28 20:27:11 2020 +0000
+++ b/gtk3/dw.c	Tue Sep 29 04:06:20 2020 +0000
@@ -8384,7 +8384,7 @@
    {
       FD_ZERO(&rd);
       FD_SET(listenfd, &rd);
-      int result;
+      int DW_UNUSED(result);
 
       maxfd = listenfd;