g++ 2.95 typeinfo::name()

Kellogg, Oliver Oliver.Kellogg@vs.dasa.de
Mon Jan 22 03:56:00 GMT 2001


Hi,

Is it correct that the typeinfo::name() method of g++-2.95 
returns a number, i.e. the length of following characters, 
prefixed to the actual name?

// This program:

#include <typeinfo>
#include <string>
#include <iostream>

class myclass {
  public:
    int i;
};

int main ()
{
  string s;
  myclass m;

  s = typeid (m).name ();
  cout << s.c_str () << endl;

  return 0;
}

// produces:
//    7myclass

FYI, other C++ compilers, e.g. Rational C++ 3.0.0b, 
return the name but without the length prefix.

Thanks,

Oliver M. Kellogg
-- oliver dot kellogg at vs dot dasa dot de


More information about the Gcc mailing list