Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ class member alignment in Xcode



It's funny that you should ask this. I just finished chasing down the very same kind of problem in our project earlier in the week.

There are two #pragmas that can change your struct alignment: "#pragma options align" or "#pragma pack". These are usually used in pairs so the packing is changed for known data structures. In our case, we were using "#pragma options align=..." and forgot to close it with "#pragma options align=reset" in a header file. Since this malformed header was included in many places, it had side-effects in each file that used it.

The compiler never complained, but I had a situation where sizeof ( myClass ) would return different sizes in different .cpp files.

So, I would be looking for #pragmas and making sure they were all closed properly.

	-Wyatt

On Feb 8, 2007, at 11:05 AM, <email@hidden> <email@hidden> wrote:


Hello,

I am having a problem with a derived class accessing members in the base
class. It looks like this:



[...]


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:
http://lists.apple.com/mailman/options/xcode-users/wwebb% 40inspiration.com


This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >C++ class member alignment in Xcode (From: <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.