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
2
u/duane11583 Jun 09 '26
un aligned on x86_64 is sub optimal this is why the default is the padding and alignment to the cache
it is all about speed.
the x86 has extra hw to handle the unaligned data