gcc 下获取 类名 来自 gtest

#include <cxxabi.h>

#include <iostream>

 

class A {

  int a;

};

 

class BXCC : public A {

  int b;

};

 

class dushishuang : public A {

  int c;

};

 

int main() {

  const char * const name =  typeid(dushishuang1).name();

  int status  = 0;

  char * const readable_name = abi::__cxa_demangle(name, 0, 0, &status);

  ::std::cout << name << ::std::endl;

  ::std::cout << readable_name << std::endl;

  return 0;

}

 

你可能感兴趣的:(gcc 下获取 类名 来自 gtest)