Differences between rel1 and rel3

Christian Ludlam chris at recoil.org
Sun Sep 7 15:26:23 PDT 2003

On 7 Sep Jason Perry wrote:

> In message <5009682e4c.christian at venice.lab> you wrote:
> > GCC is touchy about where attribute declarations go - you need something
> > like

> > #define PACKED __attribute__((packed))

> > struct ch_sob {
> >     struct ch_header header;
> >     struct ch_time time;
> >     uint8 batch;
> >     uint8 clamp;
> > } PACKED;

> Thanks, I've tried that with no apparent effect.

> Would you expect the value returned by sizeof(struct ch_sob) to be
> different when using __attribute__((packed)) than when not using it?

Yes, sizeof() should always return the correct size (in bytes). However,
something must be amiss, since your original structure was

struct data_desc
  u_int8_t  Length;
  u_int8_t  Type;
  u_int16_t version;
  u_int8_t  CountryCode;
  u_int8_t  Number;

I wouldn't expect packing this to do anything other than remove two padding
bytes from the end - everything else aligns nicely. If GCC is word-aligning
every member, then something's wrong.

Christian Ludlam
chris at recoil.org

More information about the gcc mailing list