Re: Checking alignment of data types

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

 



On 11 Mar 2004, Paul Eggert wrote:

> Remko Troncon <remko.troncon@xxxxxxxxxxxxxxxxx> writes:
>
> > Is there a predefined autoconf macro to retrieve the required alignment of
> > data types ?
>
> No.  It's not needed all that much, since you can find the alignment
> of a type in C.
>
> #include <stddef.h>
> #define alignof(type) offsetof (struct { char x; type y; }, y)

Doesn't this obtain the default alignment of the type rather than the
required alignment?  The required alignment is the alignment necessary
in order to avoid a segmentation fault.  The default alignment has the
additional consideration of efficiency.

Bob
======================================
Bob Friesenhahn
bfriesen@xxxxxxxxxxxxxxxxxxx
http://www.simplesystems.org/users/bfriesen




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux