Re: about alignment of structure

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

 



2010/5/19 Andrew Haley <aph@xxxxxxxxxx>:
> On 05/19/2010 03:29 AM, YC Wang wrote:
>
>> When gcc processes a strucure declaration, what rules it will use? As
>> far as I know, gcc is supposed to conform to the platform ABI. For
>> example, below is extracted from the SysV i386 ABI:
>>
>>  - An entire structure or union object is aligned on the same boundary as
>>  its most strictly aligned member.
>>
>>  - Each member is assigned to the lowest available offset with the
>>  appropriate alignment. This may require internal padding, depending on the
>>  previous member.
>>
>>  - A structure's size is increased, if necessary, to make it a multiple
>>  of the alignment. This may require tail padding, depending on the last
>>  member.
>>
>> So, should gcc (whatever versions) always comform to these rules
>> (assume we don't specify special attributes or options)?
>
> Yes.
>
>> I ask this question because I just read the paper
>> "stable_api_nonsense" by Greg KH from Linux kernel Documentation,
>> and begin with line 54 the paper says "Depending on the version of
>> the C compiler you use, different kernel data structures will
>> contain different alignment of structures".
>
> We try to follow the ABI but sometimes we make mistakes.  However,
> it's impossible to tell what he's talking about for sure.  You'd have
> to ask him.
>
> Andrew.
>

Actually, I had mailed him, but his mail-bot suggested me to ask
mailing lists. Maybe only himself can answer me this time. Anyway,
thank you for the reply.

YC wang


[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