Bloated Struct Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've created this typedef:

typedef struct {
  uint64_t a;
  uint64_t b;
  uint8_t c;
} my_type_t;

When I do sizeof(my_type_t), I find that it's 20 with GCC 4.0.3
(targetting i686), whereas obviously it needs only 17 bytes.  If this
has changed in a more recent version of GCC, please inform.
(Upgrading is intractable for me at the moment.)  However, I suspect
that it has not changed.  In which case, why is sizeof() bloating my
type?  Is it trying to help align every element of an array of this
type?  If so, that would be a bad performance decision in this
multicore world, where memory footprint size matters much more than
alignment, generally speaking.

I can work around this with some macro magic, but I'd rather be clean
about it.  Is there some command line switch that will fix this, e.g.
--fdont_bloat_structs?

Thanks for any insights.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux