Skip to content

Commit

Permalink
Compiler.h: add macro GCC_OLDER_THAN()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Nov 28, 2014
1 parent 4bfd104 commit 25429af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Chrono.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/util/Manual.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 25429af

Please sign in to comment.