Re: memory layouts of C++ classes

cliffc@rice.edu (Cliff Click)
Sun, 14 Aug 1994 03:26:47 GMT

          From comp.compilers

Related articles
memory layouts of C++ classes tomtzigt@frc602.intel.com (1994-08-12)
Re: memory layouts of C++ classes cliffc@rice.edu (1994-08-14)
memory layouts of C++ classes ssimmons@convex.com (1994-08-14)
Re: memory layouts of C++ classes jangr@microsoft.com (1994-08-18)
| List of all articles for this month |
Newsgroups: comp.compilers
From: cliffc@rice.edu (Cliff Click)
Keywords: C++, design, code
Organization: Center for Research on Parallel Computations
References: 94-08-087
Date: Sun, 14 Aug 1994 03:26:47 GMT

tomtzigt@frc602.intel.com (Theodore Omtzigt - MAP-Folsom) writes:


      After walking the heap to reverse engineer the memory layout
      of a class in MFC, I figured this forum might provide a better
      answer. How does a C++ compiler build the memory layout of a class
      and a derived class? Also, what is the difference in memory layout
      of a regular C++ compiler and the memory layouts used by SOM compilers
      to provide binary consistency? Thanks in advance,


Naturally, different compilers do it differently.


If I remember right, g++ places the base structure first
(using the normal C structure rules), then a virtual
function pointer if required, then any inherited classes
one after another.


Borland C places the virtual function pointer BEFORE the
first structure, at a negative offset. Inherited classes
as before.


Don't know how they handle multiple inheritance, virtual
base classes, or having the first virtual function in an
inherited class.




Cliff
--
cliffc@cs.rice.edu -- Massively Scalar Compiler Group, Rice University
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.