Browse Source

libdpkg: Add new DPKG_GCC_VERSION macro and use it

Instead of doing several checks on the different GCC macros with the
version parts, merge them into this new macro and use simple integer
arithmetic to compare the versions.
Guillem Jover 15 years ago
parent
commit
25fb807882
1 changed files with 9 additions and 4 deletions
  1. 9 4
      lib/dpkg/macros.h

+ 9 - 4
lib/dpkg/macros.h

@@ -27,7 +27,13 @@
 
 /* Language definitions. */
 
-#if defined(__GNUC__) && (__GNUC__ >= 3)
+#ifdef __GNUC__
+#define DPKG_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
+#else
+#define DPKG_GCC_VERSION 0
+#endif
+
+#if DPKG_GCC_VERSION >= 0x0300
 #define DPKG_ATTR_UNUSED	__attribute__((unused))
 #define DPKG_ATTR_CONST		__attribute__((const))
 #define DPKG_ATTR_PURE		__attribute__((pure))
@@ -45,8 +51,7 @@
 #define DPKG_ATTR_VPRINTF(n)
 #endif
 
-#if defined(__GNUC__) && \
-    ((__GNUC__ == 3 && __GNUC_MINOR__ > 2) || __GNUC__ >= 4)
+#if DPKG_GCC_VERSION > 0x0302
 #define DPKG_ATTR_NONNULL(...)	__attribute__((nonnull(__VA_ARGS__)))
 #define DPKG_ATTR_REQRET	__attribute__((warn_unused_result))
 #else
@@ -54,7 +59,7 @@
 #define DPKG_ATTR_REQRET
 #endif
 
-#if defined(__GNUC__) && (__GNUC__ >= 4)
+#if DPKG_GCC_VERSION >= 0x0400
 #define DPKG_ATTR_SENTINEL	__attribute__((sentinel))
 #else
 #define DPKG_ATTR_SENTINEL