monotone

monotone Mtn Source Tree

Root/current_exception.hh

1// Copyright (C) 2007 Zack Weinberg <zackw@panix.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef CURRENT_EXCEPTION_HH
11#define CURRENT_EXCEPTION_HH
12
13#include <typeinfo>
14
15// Add #ifdeffage here as appropriate for other compiler-specific ways to
16// get this information. Windows note: as best I can determine from poking
17// around on MSDN, MSVC type_info.name() is already demangled, and there is
18// no documented equivalent of __cxa_current_exception_type().
19#ifdef HAVE_CXXABI_H
20 #include <cxxabi.h>
21 #ifdef HAVE___CXA_DEMANGLE
22 inline char const * demangle_typename(char const * name)
23 {
24 int status = -1;
25 char * dem = abi::__cxa_demangle(name, 0, 0, &status);
26 if (status == 0)
27 return dem;
28 else
29 return 0;
30 }
31 #else
32 #define demangle_typename(x) 0
33 #endif
34 #ifdef HAVE___CXA_CURRENT_EXCEPTION_TYPE
35 #define get_current_exception_type() abi::__cxa_current_exception_type()
36 #else
37 #define get_current_exception_type() 0
38 #endif
39#else
40 #define demangle_typename(x) 0
41 #define get_current_exception_type() 0
42#endif
43
44#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status