• 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: byte alignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: byte alignment


  • Subject: Re: byte alignment
  • From: Allan Odgaard <email@hidden>
  • Date: Wed, 30 Jun 2004 13:43:26 +0200

On 30. Jun 2004, at 0:23, Markian Hlynka wrote:

but for some reason, sizeof(Ply_T) is returning 3. I think it should be
2.

No, Xcode/gcc is free to layout the structure as it likes.

My only explanation is byte alignments. Where in xcode can I change
the complier setting to turn OFF byte alignment?

You can disable byte alignment for an individual structure by setting the packed attribute, e.g.:
struct foo { uint8_t bar, fud; } __attribute__((packed));


However, what is likely to be your problem is that gcc will not let a bit field overlap two member data variables. Use uint16_t instead of 'unsigned char' (which is 8 bit, and thus will only hold 2 x 3 bits).

This will cause me some extremely undesirable behaviour!

Having your program rely on byte alignment and in-memory structure layout is probably a very bad idea.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.



References: 
 >byte alignment (From: Markian Hlynka <email@hidden>)

  • Prev by Date: XML Creation
  • Next by Date: RE: xcode-users digest, Vol 1 #485 - 12 msgs
  • Previous by thread: Re: byte alignment
  • Next by thread: XML Creation
  • Index(es):
    • Date
    • Thread