sizeof struct { short x } on arm gcc-3.2.1

Mike Stump mrs@apple.com
Fri Feb 16 23:11:00 GMT 2007


On Feb 16, 2007, at 8:57 AM, Rutger Hofman wrote:
> If I declare the struct 'packed', then it is size 2. That is enough  
> for my purposes. I hope that won't greatly change through versions...

Also, there is:

@item -mstructure-size-boundary=@var{n}
@opindex mstructure-size-boundary
The size of all structures and unions will be rounded up to a multiple
of the number of bits set by this option.  Permissible values are 8, 32
and 64.  The default value varies for different toolchains.  For the  
COFF
targeted toolchain the default value is 8.  A value of 64 is only  
allowed
if the underlying ABI supports it.

Specifying the larger number can produce faster, more efficient code,  
but
can also increase the size of the program.  Different values are  
potentially
incompatible.  Code compiled with one value cannot necessarily expect to
work with code or libraries compiled with another value, if they  
exchange
information using structures or unions.

You don't want just packed, as that will make it 1 byte aligned,  
which isn't probably what you want.  alignof () will tell you the  
alignment of something, if you want to check to make sure you got it  
right.



More information about the Gcc mailing list