C++ class member alignment in Xcode
C++ class member alignment in Xcode
- Subject: C++ class member alignment in Xcode
- From: <email@hidden>
- Date: Thu, 8 Feb 2007 11:05:54 -0800
- Importance: Normal
Hello,
I am having a problem with a derived class accessing members in the base
class. It looks like this:
In file CClassA.cpp
class classA
{
public:
short mem1;
long mem2;
Boolean mem3;
Boolean mem4;
Boolean mem5;
Boolean mem6;
Boolean mem7;
Handle mem8;
};
In file CClassB.cpp
class classB : public classA
{
UInt32 mem9;
};
If I reference mem8 from classA everything works fine. When I try to
use the handle mem8 from classB I crash. Upon investigation classB has
a different offset for mem8 then classA has. ClassA is aligning members
on a 4-byte boundary while classB is aligning on a 2-byte boundary. I
can not find any file level properties for member alignment.
I have preformed a clean rebuild of the project and get the same result.
Why does one file use 4-byte alignment while another on in the same
project uses 2-byte?
Regards,
Ron Lingl
Interactive Solutions, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden