This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sizeof and allignment on 32bit target


Thank you, Jan Zizka, Roman Kellner

I would expect that the allignment has only influence on the address of
variables, not on the total size of a structure. It looks like the compiler
calculates the size of the structure to be a multiple of the largest item in the
structure.
What I want is to allign each variable in the structure to it's own size, but
the total size of the structure to be the actual size. Is this possible?

Eric

----
  struct { unsigned char Value2; unsigned char Value3; unsigned char Value4; }
Value;
  sizeof(Value) = 3;

  struct { unsigned short Value1; unsigned char Value2; unsigned char Value3;
unsigned char Value4; } Value;
  sizeof(Value) = 6; (not 5)

  struct { unsigned long Value1; unsigned char Value2; unsigned char Value3;
unsigned char Value4; } Value;
  sizeof(Value) = 8; (not 7)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]