help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: recode "typeinfo::name()" into usable format


From: Paul Pluzhnikov
Subject: Re: recode "typeinfo::name()" into usable format
Date: Fri, 19 Jan 2007 09:55:13 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

"Grizlyk" <grizlyk1@yandex.ru> writes:

> std::unexpected() can print correct name of
> class. What function of g++ does correct name demangling?

__gnu_cxx::__verbose_terminate_handler() in 
gcc-3.4.6/libstdc++-v3/libsupc++/vterminate.cc has this code:

57          type_info *t = __cxa_current_exception_type();
58          if (t)
59            {
60              // Note that "name" is the mangled name.
61              char const *name = t->name();
62              {
63                int status = -1;
64                char *dem = 0;
65                
66                dem = __cxa_demangle(name, 0, 0, &status);
67
68                fputs("terminate called after throwing an instance of '", 
stderr);
69                if (status == 0)
70                  fputs(dem, stderr);
71                else
72                  fputs(name, stderr);
73                fputs("'\n", stderr);
74
75                if (status == 0)
76                  free(dem);
77              }

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]