This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
sizeof struct { short x } on arm gcc-3.2.1
- From: Rutger Hofman <rutger at cs dot vu dot nl>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 16 Feb 2007 16:10:08 +0100
- Subject: sizeof struct { short x } on arm gcc-3.2.1
Hello list,
I did a quick search in the archives but I found nothing appropriate.
My (embedded) development system is gcc-3.2.1 arm-elf. I don't really
understand its value for sizeof(struct { short x }).
Given the following program:
<code>
#include <stdio.h>
int
main(int argc, char *argv[])
{
struct {
short s;
} s_sh;
printf("sizeof s_sh %d\n", (int) sizeof s_sh);
printf("sizeof short %d\n", (int) sizeof(short));
return 0;
}
</code>
it prints:
sizeof s_sh 4
sizeof short 2
Why isn't the size of this struct also 2? I assume this is to do with
alignment, but even then I don't really understand. To create an array
of such structs, no padding seems required.
Or has this already been fixed in not so ancient versions of arm-elf-gcc?
Thanks for enlightening me,
Rutger Hofman
VU Amsterdam