Re:The Lost Art of C Structure Packing
by sprw121 on Wednesday February 18, 2015 @11:59AM
(#9069516)
Or we could use __attribute__((packed))?
[ Parent
| on HN ]
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.
#pragma(pack) or __attribute__((packed)) still won't re-order structure fields for optimal alignment. The directive/extension only prevents holes in the structure.