News for hackers. Stuff that matters.
Re:The Lost Art of C Structure Packing by sprw121 on Wednesday February 18, 2015 @11:59AM (#9069516)
Or we could use __attribute__((packed))?
Re:The Lost Art of C Structure Packing by wvenable on Wednesday February 18, 2015 @02:30PM (#9070461)
That directly trades size for less efficient code. The structure packing described in the article keeps the same code efficiency while decreasing the size.

There are good reasons (as mentioned in the article) for this feature but it's not equivalent to manual structure packing.

Re:The Lost Art of C Structure Packing by TorKlingberg on Wednesday February 18, 2015 @12:29PM (#9069719)
That is not standard C but a GCC extension, although clang probably supports it.
Re:The Lost Art of C Structure Packing by grok2 on Wednesday February 18, 2015 @01:07PM (#9069963)
#pragma(pack) or __attribute__((packed)) still won't re-order structure fields for optimal alignment. The directive/extension only prevents holes in the structure.
Re:The Lost Art of C Structure Packing by kryptiskt on Wednesday February 18, 2015 @03:36PM (#9070766)
And then we might get fields that cross word boundaries, making every access unaligned or way worse on architectures that haven't got addressable bytes.