This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: structure size and structure element offset calculation issue
- From: Ian Lance Taylor <iant at google dot com>
- To: Sivaprasad <sivaprasad dot pv at redpinesignals dot com>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 27 May 2014 06:25:42 -0700
- Subject: Re: structure size and structure element offset calculation issue
- Authentication-results: sourceware.org; auth=none
- References: <5379DBEA dot 3050903 at redpinesignals dot com> <CAH6eHdSxUTYqD6w4eJaqbZxe59JGFrTuXbAEkvt3vZsaxq+9wQ at mail dot gmail dot com> <5379F909 dot 9010906 at redpinesignals dot com> <CAH6eHdQ1SyaXaQ997oXuBfjF30wigOqzbjmaDUxTqZAq33pHbA at mail dot gmail dot com> <537F1DA1 dot 7030407 at redpinesignals dot com> <CAH6eHdRqyY1qfeEg=DVxMaxegDG0YU+mgQQ7AGNL2sxqP8z2rw at mail dot gmail dot com> <537F527E dot 8060106 at redpinesignals dot com> <CAKOQZ8wnz8ghWjYKDyyQ2ocak9SVVbJ3ZZzivNwKT5ak8SS6RQ at mail dot gmail dot com> <5384234D dot 6090709 at redpinesignals dot com>
On Mon, May 26, 2014 at 10:31 PM, Sivaprasad
<sivaprasad.pv@redpinesignals.com> wrote:
>
> By packing the structure, issue got solved but generating more code.
> How can I make our cross compiler to generate size of struct { short s;} as
> 2 instead of 4 ?
This is not quite the question you asked last time. I would expect
that sizeof(struct{short s;}) would return 2. It does on x86.
> Is it required to change any macro's in port.h?
If for your private port sizeof(struct{short s;}) does not return 2
(and assuming that sizeof(short) does return 2), then, yes, you can
change something in your private port to fix that. It's not the
default case, so it would be something unusual that your port is
doing. For example, perhaps you have defined ADJUST_FIELD_ALIGN.
Ian