r/C_Programming • u/anduygulama • Jun 09 '26
packed attribute for structs
Why don't C compilers automatically optimize/pack structures instead of requiring explicit attributes?
2
Upvotes
r/C_Programming • u/anduygulama • Jun 09 '26
Why don't C compilers automatically optimize/pack structures instead of requiring explicit attributes?
View all comments
Show parent comment
1
u/SyntheticDuckFlavour Jun 11 '26
That extra code is probably going to be almost certainly negligible in the grand scheme of things. Typically you space optimally pack data when the pay-off is actually worth it. For example, when allocating and working with huge blocks of data.