aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-11-28 18:57:48 +0100
committerMax Kellermann <max@duempel.org>2014-11-28 19:09:52 +0100
commit25429af1227469e1b8d1c43d5da8d9d1b109fe8c (patch)
tree4cb57fad715395ced7f1cc38abb0b4b497758b61 /src
parent4bfd104a23b3abbdfb2ab5dee88fcaec6aea3cf0 (diff)
downloadmpd-25429af1227469e1b8d1c43d5da8d9d1b109fe8c.tar.gz
mpd-25429af1227469e1b8d1c43d5da8d9d1b109fe8c.tar.xz
mpd-25429af1227469e1b8d1c43d5da8d9d1b109fe8c.zip
Compiler.h: add macro GCC_OLDER_THAN()
Diffstat (limited to '')
-rw-r--r--src/Chrono.hxx2
-rw-r--r--src/Compiler.h12
-rw-r--r--src/util/Manual.hxx4
3 files changed, 13 insertions, 5 deletions
diff --git a/src/Chrono.hxx b/src/Chrono.hxx
index cc87c5ba1..960a6364c 100644
--- a/src/Chrono.hxx
+++ b/src/Chrono.hxx
@@ -26,7 +26,7 @@
#include <utility>
#include <cstdint>
-#if defined(__GNUC__) && !GCC_CHECK_VERSION(4,7) && !defined(__clang__)
+#if GCC_OLDER_THAN(4,7)
/* std::chrono::duration operators are "constexpr" since gcc 4.7 */
#define chrono_constexpr gcc_pure
#else
diff --git a/src/Compiler.h b/src/Compiler.h
index 74dc65a13..d64ee283b 100644
--- a/src/Compiler.h
+++ b/src/Compiler.h
@@ -31,13 +31,21 @@
#define GCC_CHECK_VERSION(major, minor) \
(defined(__GNUC__) && GCC_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
+/**
+ * Are we building with gcc (not clang or any other compiler) and a
+ * version older than the specified one?
+ */
+#define GCC_OLDER_THAN(major, minor) \
+ (defined(__GNUC__) && !defined(__clang__) && \
+ GCC_VERSION < GCC_MAKE_VERSION(major, minor, 0))
+
#ifdef __clang__
# define CLANG_VERSION GCC_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
# if __clang_major__ < 3
# error Sorry, your clang version is too old. You need at least version 3.1.
# endif
#elif defined(__GNUC__)
-# if !GCC_CHECK_VERSION(4,6)
+# if GCC_OLDER_THAN(4,6)
# error Sorry, your gcc version is too old. You need at least version 4.6.
# endif
#else
@@ -138,7 +146,7 @@
#if defined(__cplusplus)
/* support for C++11 "override" was added in gcc 4.7 */
-#if !defined(__clang__) && !GCC_CHECK_VERSION(4,7)
+#if GCC_OLDER_THAN(4,7)
#define override
#define final
#endif
diff --git a/src/util/Manual.hxx b/src/util/Manual.hxx
index 3cdf7d0df..fa4b00615 100644
--- a/src/util/Manual.hxx
+++ b/src/util/Manual.hxx
@@ -35,7 +35,7 @@
#include <new>
#include <utility>
-#if !defined(__clang__) && __GNUC__ && !GCC_CHECK_VERSION(4,8)
+#if GCC_OLDER_THAN(4,8)
#include <type_traits>
#endif
@@ -54,7 +54,7 @@
*/
template<class T>
class Manual {
-#if !defined(__clang__) && __GNUC__ && !GCC_CHECK_VERSION(4,8)
+#if GCC_OLDER_THAN(4,8)
/* no alignas() on gcc < 4.8: apply worst-case fallback */
__attribute__((aligned(8)))
#else