This is the mail archive of the gcc-help@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]

Class Object layout in memory


How does the GNU compiler (2.96 or 3.3 or PPC) layout instances of C++ class objects in memory? 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


Joe Lovelace Winnipeg MB, Canada



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