• 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
Re: sizeof(aStruct) in Xcode 4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sizeof(aStruct) in Xcode 4


  • Subject: Re: sizeof(aStruct) in Xcode 4
  • From: lbland <email@hidden>
  • Date: Tue, 21 Jun 2011 15:56:19 -0400

hi-

On Jun 21, 2011, at 3:39 PM, McLaughlin, Michael P. wrote:

> sizeof(AA) and sizeof(BB) both come out as 16 even though they "should" be 12.   ...

I think it's nice to use struct, and a lot of people get away with using struct, just for your reason; but I don't think there is any guarantee the way the fields are packed and aligned or if there are holes or not.

> Clearly, I am confused by the proliferation of int types and unsure what the recommended practice should be to avoid these errors.

... you can do what I do...

memcpy(byteBuffer + byteOffset, (void *)&my_double, 8);

and stuff like that :-)

... if you put it into an archive then you need to take care of many other details like endian but since you are piping it you probably don't have to worry about that.

... don't know about llvm, but in gcc there are also some pragmas that help with field alignment.

thanks!-

-lance

 _______________________________________________
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

References: 
 >sizeof(aStruct) in Xcode 4 (From: "McLaughlin, Michael P." <email@hidden>)

  • Prev by Date: sizeof(aStruct) in Xcode 4
  • Next by Date: Re: sizeof(aStruct) in Xcode 4
  • Previous by thread: sizeof(aStruct) in Xcode 4
  • Next by thread: Re: sizeof(aStruct) in Xcode 4
  • Index(es):
    • Date
    • Thread