Re: byte alignment
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.