"Joe Lovelace" <pintose@xxxxxxxxxxx> writes: > How does the GNU compiler (2.96 or 3.3 or PPC) layout instances of C++ > class objects in memory? It varies. For C++ it is mostly described here: http://www.codesourcery.com/cxx-abi/abi.html (It says Itanium, but gcc uses it for all targets.) > For example, > >class CMyClass{ > private: > >int a; > >char b; > >short c: > >}; > > > >CMyClass instance; > > > > if &instance is 0x1000, would the memory layout be as follows? Or is > > it more complex? (Of course the items may be aligned to the > > processors alignment boundaries ie 32-bit) > > > >instance a b c > >0x1000 0x1000 0x1004 0x1005 Typically 'c' would be aligned to a 2 bit boundary, and thus would be at address 0x1006. The precise alignment requirements depend on the processor. Ian