how do I demangle the name from typeinfo(obj).name()?

Larry Evans jcampbell3@prodigy.net
Sat Oct 14 04:21:00 GMT 2000


David Baraff wrote:

> [Apologies for cross-post; couldn't decide which one was really
> correct.]
> I'm trying to demangle names that come back from typeinfo, e.g.
>
>     cout << typeinfo(someObject).name() << "\n";
>
> Some of the things I get out are successfully demangled using the
> c++filt program (with
> option -edg) but some simple things are not!!  I add the required "__"
> (two underscores)
> but that doesn't always work.
>
> Here are some outputs:
>     6foobar    /* demangles after adding __ */
>     t4list2Z6foobarZt15TaggedAllocator1Z6foobar  /* demangles after
> adding __ */
>     i             /* doesn't demangle no matter what */
>     Fv_i      /* doesn't demangle no matter what */
>
> Sadly, the last two cases are, respectively, printing the signatures
> of an int, and main.
>
> Could someone PLEASE tell me how to consistently demangle these names?

The attached code works for me.


More information about the Gcc-help mailing list