• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
C++ class member alignment in Xcode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: C++ class member alignment in Xcode
      • From: John Daniel <email@hidden>
  • Prev by Date: What are all these com.apple.Xcode_ folders?
  • Next by Date: Re: C++ class member alignment in Xcode
  • Previous by thread: What are all these com.apple.Xcode_ folders?
  • Next by thread: Re: C++ class member alignment in Xcode
  • Index(es):
    • Date
    • Thread