This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Shaun Jackman writes: > I compiled the following snippet with > -mstructure-size-boundary=8 > Unfortunately, sizeof( s) and sizeof( s0) both report 16 (should be 14). > Through inspection with GCC, there's no padding between the members, so I > assume the padding is being added to the end. > I thought this is what -ms.s.b. was supposed to prevent. Not quite. > Help? > > typedef struct { > int src; > int dst; > char mbz; > char protocol; > short length; > short checksum; > } s; If you want to make this 14 bytes, you also have to mark it as packed. typedef struct { int src; int dst; char mbz; char protocol; short length; short checksum; } s __attribute__ ((packed)); // IIRC -ms.s.b. applies after packing concerns. Note that on other targets where structure-size-boundary is 8 (e.g. sparc) sizeof (s0) == 16 which is what it should be. The padding is for alignment requirements: if there's an array of them, you want each array element properly aligned. ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |