* Andy Lutomirski <l...@amacapital.net> wrote:

> > So I might be missing something, but what generic uses does it 
> > have, beyond structures that have some rare size related 
> > weirdness, such as alignment attributes? In 99% of the cases:
> >
> >    sizeof(struct) == offsetofend(struct, last_member)
> >
> > right?
> 
> struct foo {
>     u64 a;
>     char b;
> };
> 
> sizeof(struct foo) will be 16, but offsetofend(struct foo, b) will be
> 9 on most platforms, right?

I knew I missed something obvious :-)

Let me attempt to get it right:

When the next byte after the last member of a structure is not aligned 
to the largest alignment requirement of any structure member, then the 
structure grows (is padded) and offsetofend() < sizeof().

'packed' or 'aligned' attributes will modify the largest alignment 
requirement value so they are a common but not only mechanism for this 
to be the case.

Thanks,

        Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to