Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2003-12-10 10:29:42


Cool! This makes life simpler. BTW, just for general reference the
call is in the abi namespace, not cxxabi :

#ifdef __GNUC__
#include "cxxabi.h"
#endif

template<class T>
void write_typeid()
{
     #ifdef __GNUC__
     // need to demangle C++ symbols
     char* ptr = NULL;
     std::size_t len;
     int stat;

     const std::string mangled = typeid(T).name();

     std::cout << abi::__cxa_demangle(mangled.c_str(),ptr,&len,&stat) <<
std::endl;
     #else
     std::cout << typeid(T).name() << std::endl;
     #endif

     std::cout << std::endl;
}

Very handy...

Matthias

>> Yeah, sorry about that one. GCC outputs mangled typenames when you
>> use typeid(T).name(), so you need to run a utility called c++filt to
>> demangle them into something comprehensible by humans
>
> You might have a look at cxxabi::__cxa_demangle; it can do the same
> thing inside your executable.
>
> --
> Dave Abrahams
> Boost Consulting
> www.boost-consulting.com
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
------------------------------------------------------------------------
---------------------------
Matthias Schabel, Ph.D.
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
801-587-9413 (work)
801-585-3592 (fax)
801-706-5760 (cell)
801-484-0811 (home)
mschabel at ucair med utah edu


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk