This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++ 2.95 typeinfo::name()


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]