lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Struct packing/alignment problems


From: Timmy Brolin
Subject: Re: [lwip-users] Struct packing/alignment problems
Date: Tue, 04 May 2004 22:49:23 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

Ok, I found "something" here: http://std.dkuug.dk/jtc1/sc22/open/n2794/n2794.txt It is not the final ANSI C99 document, but the latest publicaly available version. "Each non-bit-field member of a structure or union object is aligned in an implementation-defined manner appropriate to its type."

Not exactly a very precise statement, but it does indicate that fields are aligned to the natural boundary of it's type.
What do you think?

Timmy


Leon Woestenberg wrote:


Hello all,

Timmy Brolin wrote:


Why would they be put on 4 byte boundaries? The natural boundary of u16s is 2 bytes, not 4 bytes. Putting a u16 on a 4 byte boundary changes nothing.

>
OK, we all seem to agree on the fact that types should always be aligned on their natural alignment boundaries.

The real question is whether the compiler is allowed to add *extra*
padding (for performance reasons or whatever). If a compiler is free
to add extra padding (i.e. other than for alignment reasons) we need
to keep it from doing this (through packing).

Can we give live examples of extranous padding?

I remember the packing stuff being added for *some* reason, although
I cannot remember the specific compiler or platform.

Regards,

Leon.



_______________________________________________
lwip-users mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/lwip-users







reply via email to

[Prev in Thread] Current Thread [Next in Thread]