ron minnich wrote:
On Wed, Sep 10, 2008 at 1:37 PM, Stefan Reinauer stepan@coresystems.de wrote:
Just curious: Why would you say packed is asking for trouble?
it's actually burned me in the past, but I am fine with it when needed. It's not needed for sysinfo for example. Some of our uses seem gratuitous.
There are cases where people naively used packed and ended up slowing down the programs by several orders of magnitude (on alpha for example).
The Xen guys used it at first and then removed it. It's worth avoiding if you can.
Absolutely. The only reason to use it is when
a) reading from binary files directly into a struct b) using a struct to access hardware
When GCC adds padding to the struct, it does that to increase speed when accessing the members by removing the need to do slow, unaligned accesses.
That said, using it for sysinfo sounds like a bad idea, unless writing sysinfo and reading it again is done by 2 different compilers.