]> granicus.if.org Git - icinga2/commitdiff
Build fix for Clang >= 3.4.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 20 Apr 2014 12:09:01 +0000 (14:09 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 20 Apr 2014 12:12:20 +0000 (14:12 +0200)
Fixes #5360

lib/base/exception.cpp

index b255440dad96065fb99ccfa4602242c7d9f7949e..1f8cc1b38ac771a0e2a2b150399d95bdf08a15a4 100644 (file)
 
 #include "base/exception.h"
 
+#ifndef _MSC_VER
+#      include <cxxabi.h>
+#endif /* _MSC_VER */
+
 using namespace icinga;
 
 static boost::thread_specific_ptr<StackTrace> 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<std::type_info *>(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<std::type_info *>(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)
 {