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

1

u/HobbyQuestionThrow Jun 10 '26

Not just slow, it can also cause really fun race conditions even when two threads are not accessing the same "field" in your packed structure.