From 088b15e964fc20248364fd5da445667bef833141 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 20 Apr 2014 14:09:01 +0200 Subject: [PATCH] Build fix for Clang >= 3.4. Fixes #5360 --- lib/base/exception.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/base/exception.cpp b/lib/base/exception.cpp index b255440da..1f8cc1b38 100644 --- a/lib/base/exception.cpp +++ b/lib/base/exception.cpp @@ -19,6 +19,10 @@ #include "base/exception.h" +#ifndef _MSC_VER +# include +#endif /* _MSC_VER */ + using namespace icinga; static boost::thread_specific_ptr l_LastExceptionStack; @@ -44,11 +48,19 @@ void icinga::RethrowUncaughtException(void) #endif /* __GLIBCXX__ || _WIN32 */ } -#ifndef _WIN32 +#ifndef _MSC_VER +# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ > 3) +# define TYPEINFO_TYPE std::type_info +# else +# define TYPEINFO_TYPE void +# endif + extern "C" -void __cxa_throw(void *obj, void *pvtinfo, void (*dest)(void *)) +void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *)) { - typedef void (*cxa_throw_fn)(void *, void *, void (*) (void *)) __attribute__((noreturn)); + std::type_info *tinfo = static_cast(pvtinfo); + + typedef void (*cxa_throw_fn)(void *, std::type_info *, void (*)(void *)) __attribute__((noreturn)); static cxa_throw_fn real_cxa_throw; #ifndef __GLIBCXX__ @@ -62,7 +74,6 @@ void __cxa_throw(void *obj, void *pvtinfo, void (*dest)(void *)) #ifdef __GLIBCXX__ void *thrown_ptr = obj; - const std::type_info *tinfo = static_cast(pvtinfo); const std::type_info *boost_exc = &typeid(boost::exception); const std::type_info *user_exc = &typeid(user_error); @@ -92,9 +103,9 @@ void __cxa_throw(void *obj, void *pvtinfo, void (*dest)(void *)) } #endif /* __GLIBCXX__ */ - real_cxa_throw(obj, pvtinfo, dest); + real_cxa_throw(obj, tinfo, dest); } -#endif /* _WIN32 */ +#endif /* _MSC_VER */ StackTrace *icinga::GetLastExceptionStack(void) { -- 2.40.0