http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51568
--- Comment #2 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2011-12-15 17:27:19 UTC --- (In reply to comment #1) > On linux sizeof (struct rec) is 7, so how do you expect an unsigned (size = 4) > to hold the entire value? > > If you want a packed enum, you need to specify the packed on the element > declaration, not just on the overall structure: > > struct rec { > unsigned short w; > unsigned char c; > enum en e __attribute__((packed)); > } __attribute__((packed)); Actually that doesn't work. The only ways to pack the enum into 8 bits are to either: 1) Use -fshort-enums (ABI change) 2) Use a bitfield expression in your struct. struct rec { unsigned short w; unsigned char c; enum en e:8; } __attribute__((packed)); Sorry for the confusion.