summaryrefslogtreecommitdiff
path: root/src/Compiler.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-26 14:26:31 +0100
committerMax Kellermann <max@duempel.org>2014-12-26 14:28:52 +0100
commit940cab8620428f21e6d0c9f4b11893b1f44ce610 (patch)
tree9b4771f1fce4e0e95f1507f021aa7587b7ba366d /src/Compiler.h
parent5b84c99d793bf9b78cf28b462593775c32a3ce83 (diff)
parent665031467a55a32be306191514ac81f73ac41de7 (diff)
Merge branch 'v0.18.x' into v0.19.x
Diffstat (limited to 'src/Compiler.h')
-rw-r--r--src/Compiler.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/Compiler.h b/src/Compiler.h
index 44a87c7ba..fea971526 100644
--- a/src/Compiler.h
+++ b/src/Compiler.h
@@ -20,33 +20,45 @@
#ifndef COMPILER_H
#define COMPILER_H
-#define GCC_CHECK_VERSION(major, minor) \
- (defined(__GNUC__) && \
- (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
+#define GCC_MAKE_VERSION(major, minor, patchlevel) ((major) * 10000 + (minor) * 100 + patchlevel)
#ifdef __GNUC__
-#define GCC_VERSION (__GNUC__ * 10000 \
- + __GNUC_MINOR__ * 100 \
- + __GNUC_PATCHLEVEL__)
+#define GCC_VERSION GCC_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0
#endif
+#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 (__clang_major__ * 10000 \
- + __clang_minor__ * 100 \
- + __clang_patchlevel__)
+# 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
# warning Untested compiler. Use at your own risk!
#endif
+/**
+ * Are we building with the specified version of clang or newer?
+ */
+#define CLANG_CHECK_VERSION(major, minor) \
+ (defined(__clang__) && \
+ CLANG_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
+
#if GCC_CHECK_VERSION(4,0)
/* GCC 4.x */
@@ -141,7 +153,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