Topic: RTTI in terms of C


Author: vinoski@apollo.hp.com (Steve Vinoski)
Date: Mon, 20 Dec 1993 01:21:14 GMT
Raw View
In article <JEFFT.93Dec19163259@netcom2.netcom.com> jefft@netcom2.netcom.com (Jeff Thompson) writes:
>Where can I read about how RTTI is usually implemented "in terms of
>C".  Would the ANSI/ISO C++ working paper be the right place, and if
>so where can I get it?

You might check out "A Portable Implementation of C++ Exception
Handling", Cameron, et. al., 1992 Usenix C++ Conference Proceedings,
pp. 225-243.  It shows at least part of a RTTI mechanism, since a C++
exception handling implementation pretty much requires some form of
RTTI mechanism under the covers.  In fact, that requirement is but a
small part of why RTTI was added to the language - the mechanism has
to be there to support exception handling anyway, so might as well
make it directly useful to the user too.

--steve

Steve Vinoski  vinoski@apollo.hp.com    (508)436-5904
Distributed Object Computing Program    fax: (508)436-5122
Hewlett-Packard, Chelmsford, MA 01824




Author: simon@sco.COM (Simon Tooke)
Date: Wed, 22 Dec 1993 20:32:35 GMT
Raw View
In <JEFFT.93Dec19163259@netcom2.netcom.com> jefft@netcom2.netcom.com (Jeff Thompson) writes:


>Where can I read about how RTTI is usually implemented "in terms of
>C".  Would the ANSI/ISO C++ working paper be the right place, and if
>so where can I get it?

>Thanks,
>Jeff

Standards don't usually mandate implementation (although you can always find
parts of standards that are mandated by expected implementation, such as the
connection between RTTI and polymorphic classes).  Thus, you shouldn't bother
looking at the working paper.

A typical implementation follows.

Polymorphic classes (those with virtual functions or inheriting from a
polymorphic class) have "hidden" pointrs to virtual function tables as one
of the (accessible only by compiler guts) data members.  To call a virtual
function, the "C" code looks somewhat like

 (*(pointer->vtable_pointer)[function_number])(args)

indirecting through the pointer to the vtbl pointer, into the table to get
the address of the function.

The run-time-type info is usually stored as a pointer in the vtbl.

This is about as clear as I feel like getting; our office "winter holiday"
party just started.  (I hate PC!)

-simon






Author: jefft@netcom2.netcom.com (Jeff Thompson)
Date: Mon, 20 Dec 1993 00:32:59 GMT
Raw View
Where can I read about how RTTI is usually implemented "in terms of
C".  Would the ANSI/ISO C++ working paper be the right place, and if
so where can I get it?

Thanks,
Jeff