Hello Derek, On Thu, 2006-04-27 at 08:30 -0400, Derek Guerdon wrote: > Timmy Brolin wrote: > > >Well, there was a long discussion about that two years ago. According to > >C standards adatatype may not have alignment requirements larger than > >its natural alignment, and padding may be introduced into structs to > >algin the fields in the struct. This would suggest that as long as we > >design the structs to be perfectly aligned, no compiler will add extra > >padding. > > I think this is a misinterpretation of the C standard.
Agreed. >... > > Given the freedom that the standard allows compilers in using padding > bytes, there is no real way to design a structure that is guaranteed > not to have padding bytes. > Yes, that must be the design constraint for the code. Assume padding everywhere unless explicitly compile-time-controlled. It can always be solved run-time, by copying a structure into a packed structure so that its memory layout can be sent on the wire as-is. However, in lwIP we tried hard to have the compiler put the bytes in the right spot by packing directives or otherwise, and have these compiled in. As Curt mentions, this will surely be sub-optimal, but worst case is still doing everything run time, AFAICS. If we can do better, I would like to hear. Regards, Leon. _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
