| ▲ | taminka 14 hours ago | |
so they're ordered, which i didn't dispute, but alignment is implementation defined, so it could be aligned to the biggest field (like in the article), or packed in whatever (sequential) order the particular platform demands, which was my initial point | ||
| ▲ | steveklabnik 14 hours ago | parent [-] | |
Ah, sorry, you're right I forgot about alignment. Yes, alignment is implementation defined, paragraph 16: > Each non-bit-field member of a structure or union object is aligned in an implementation-defined manner appropriate to its type. But, I still don't think that what you've said is true. This is because alignment isn't decided per-object, but per type. That bit is covered more fully in 6.2.8 Alignment of objects. You also have to be able to take a pointer to a (non-bitfield) member, and those pointers must be aligned. This is also why __attribute__((packed)) and such are non-standard extensions. Then again: I have not passed the C specification lawyer bar, so it is possible that I am wrong here. I'm just an armchair lawyer. :) (but for padding, yes, that's correct.) | ||