Re: sizeof and allignment on 32bit target

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

 



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 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