type_info::name question

Nathan Myers ncm@nospam.cantrip.org
Wed Sep 16 21:52:00 GMT 1998


Thomas Kunert wrote:
> 
> Alexandre Oliva wrote:
> >
> > Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de> writes:
> >
> > > Is there any possibility to get the class name from type_info::name?
> >
> > You might run `c++filt' and feed it the result of type_info::name(),
> > but you may prefer to create a library containing the unmangler
> > functions from c++filt and link your program with it.
> 
> IMHO, type_info::name isn't useful at all if it returns some cryptic
> string. Is there some intention behind that behavior or is it just the
> shortest way towards conformance? Almost everybody who wants to use
> that function, would like it to return some readable typename.

Sorry, I don't agree.  The industrial use of type_info::name is to 
generate a key to represent a type for streamed object representations.
One desirable quality of this name is that it be short and quickly
generated.  Squangling minimizes length. 

However, tying the RTTI name to the mangling scheme of the moment makes 
it harder to be compatible with other implementations, or across versions 
of egcs itself, which could be important for persistent data.  I imagine 
a future need for a compiler flag that chooses the RTTI name convention, 
choosing between mangling, squangling, and some POSIX- or CORBA-specified 
convention.

Nathan Myers
ncm@cantrip.org



More information about the Gcc mailing list