r/C_Programming • • Jun 09 '26

packed attribute for structs

Why don't C compilers automatically optimize/pack structures instead of requiring explicit attributes?

2 Upvotes

24 comments sorted by

View all comments

Show parent comment

5

u/veryusedrname Jun 09 '26

Not always trade-off, dead-code elimination and constant folding are usually come without a downside.

4

u/der_pudel Jun 09 '26

Well... I could argue that trade-off in those case is more complex compiler, but I wont. You got me.

2

u/rasputin1 Jun 09 '26

the tradeoff is reduced code. I want as much code as possible dammit!