That's why the layout in general is important, but not the order - if you need specific field offsets you use a pack attribute. The vast majority of types don't need that though (which is why compilers are free to add padding by default) and they could be safely re-ordered
would the compiler have freedom to arbitrarily change layout of the flexible struct? if so, you couldnt link object files produced by different compilers
View all comments
Show parent comment
6
u/Nicksaurus Feb 23 '26
That's why the layout in general is important, but not the order - if you need specific field offsets you use a
packattribute. The vast majority of types don't need that though (which is why compilers are free to add padding by default) and they could be safely re-ordered