This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: structure size
> ----------------------------------------------------------------------------
> struct xyzzy {
> short a;
> int b;
> } __attribute__((packed));
>
> struct xyzzy data;
>
> int
> fred(void)
> {
> data.b = 42;
> }
> ----------------------------------------------------------------------------
>
> Compile with arm-elf-gcc -S. The assignment to data.b is implemented
> using four separate strb instructions, as I would expect. If you try
> reading data.b instead there will be four ldrb instructions plus
> appropriate manipulation.
It looks like gcc 3.3 for H8 "does the right thing" as well.
After looking at the contortions it has to go through to access
misaligned struct fields, one would certainly try to avoid
them.
--
Grant Edwards
grante@visi.com
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss