From e0c452bb00e42b01a11efe5e7cc2a6bcddb54bb6 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 28 Aug 2013 16:49:58 +0200 Subject: [PATCH] Build fix for --enable-debug. --- lib/base/debug.h | 12 +++++++++--- lib/base/object.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/base/debug.h b/lib/base/debug.h index 88d1d87dc..9587f47f0 100644 --- a/lib/base/debug.h +++ b/lib/base/debug.h @@ -24,14 +24,20 @@ #include #ifdef NDEBUG -# define ASSERT(expr) ((void)0) +# if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define ASSERT(expr) __builtin_unreachable() +# else +# define ASSERT(expr) ((void)0) +# endif #else /* NDEBUG */ -# define ASSERT(expr) define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__)) +# define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__)) #endif /* NDEBUG */ #define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__)) -inline void icinga_assert_fail(const char *expr, const char *file, int line) +int icinga_assert_fail(const char *expr, const char *file, int line) __attribute__((noreturn)); + +inline int icinga_assert_fail(const char *expr, const char *file, int line) { fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr); abort(); diff --git a/lib/base/object.h b/lib/base/object.h index 2fe2c37be..00fc8b414 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -21,12 +21,12 @@ #define OBJECT_H #include "base/i2-base.h" +#include "base/debug.h" #include #ifndef _DEBUG #include #else /* _DEBUG */ -#include "base/utility.h" #include #endif /* _DEBUG */