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]
Other format: [Raw text]

[C++] Inheritance chain enumeration


Consider a class hierarchy with single inheritance, as follows:

struct A {

    virtual ~A() = default;
}

struct B : public A {

    virtual ~B() = default;
};

and

   A* p = new B();

then how can I get the type_info object of the base class of B?
Or, in other words, how do I enumerate the chain of base classes
starting with a pointer to an object? Of course I mean a GCC-internals
-aware way. The following short document:

http://www.codesourcery.com/public/cxx-abi/abi.html#rtti

says that

"For similar reasons, we only keep direct base information about
a class type. Indirect base information can be found by chasing
type_info pointers (and care should be taken to determine
ambiguous base class types)."

Namely, where do you keep the "direct base information about
a class type" and what data structures from libstdc++ should I
become familiar with? And the last question: is the format
expected to stable in terms of GCC development?

Best regards
Piotr Wyderski


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