[glib] macros: make G_GNUC_CHECK_VERSION() portable



commit d44afbadda8a57da3002def2fb82ee4d0bd86788
Author: Christian Hergert <chergert redhat com>
Date:   Sun Nov 26 16:00:46 2017 -0800

    macros: make G_GNUC_CHECK_VERSION() portable
    
    This removes the use of defined() in a macro expansion, which may not be
    portable to some pre-processors. Instead, we hoist the defined check
    outside the macro expansion.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790877

 glib/gmacros.h |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 7b980fb..4ef1436 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -37,11 +37,14 @@
  */
 #include <stddef.h>
 
+#ifdef __GNUC__
 #define G_GNUC_CHECK_VERSION(major, minor) \
-    (defined(__GNUC__) && \
-     ((__GNUC__ > (major)) || \
-      ((__GNUC__ == (major)) && \
-       (__GNUC_MINOR__ >= (minor)))))
+    ((__GNUC__ > (major)) || \
+     ((__GNUC__ == (major)) && \
+      (__GNUC_MINOR__ >= (minor))))
+#else
+#define G_GNUC_CHECK_VERSION(major, minor) 0
+#endif
 
 /* Here we provide G_GNUC_EXTENSION as an alias for __extension__,
  * where this is valid. This allows for warningless compilation of


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]