Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Re: Misaligned structure fields, works regardless... Structure packing?

2005-12-23 by Tom Walsh

Thiadmer Riemersma (ITB CompuPhase) wrote:

>>What I meant to do is have all members in the structure to be packed
>>relative to each other (i.e. no padding between the fields), but
>>aligning the first member to its "natural alignment".
>>    
>>
>
>I just found my error. I was declaring structs as:
>
>	typedef struct tagMYSTRUCT {
>		long member1   __attribute__((packed));
>		short member2  __attribute__((packed));
>		short member3  __attribute__((packed));
>	} __attribute__((packed)) MYSTRUCT;
>
>What I *should* have done is to apply the __attribute__((packed)) to
>the individual members, bot *not* to the structure as a whole.
>
>  
>
:-)  Sometimes ya' just gotta look at the code. 

Cheers!

TomW


-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.