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
24
u/mustbeset Feb 23 '26
Look at some protocol headers, hardware Interfaces and you know why the order is important.