[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Checking alignment of data types
From: |
Bob Friesenhahn |
Subject: |
Re: Checking alignment of data types |
Date: |
Fri, 12 Mar 2004 09:07:37 -0600 (CST) |
On 11 Mar 2004, Paul Eggert wrote:
> Remko Troncon <address@hidden> 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
address@hidden
http://www.simplesystems.org/users/bfriesen