__alignof__(void)

Nathan Sidwell nathan@acm.org
Wed Sep 9 20:50:00 GMT 1998


Todd Vierling wrote:
> 
> On Tue, 8 Sep 1998, Nathan Sidwell wrote:
> 
> : IMHO a useful value to return would be the maximum alignment for any
> : type.
> 
> So how do you determine this `maximum alignment' in a MI fashion?
> This would have to be a MD hack at best.
No, the define BIGGEST_ALIGNMENT already exists to tell gcc this. See
gcc.info-21 for details.

> ...And for LP64 SPARC, it would need to be "16", as doubles are 16-byte
> aligned even though "long long" is only 8 bytes.
For such an ABI, BIGGEST_ALIGNMENT would be (at least) 128. I was just
pointing out the different behaviour on my sparc box.

Having __alignof__(void) tell you this, would allow you to _avoid_ such
hacks to guess a value. On my sparc box, long doubles are indeed 16
bytes, but they are aligned to 8 byte boundaries.

In summary,
1) the knowledge already exists inside gcc
2) this exports that information to user code
3) the current meaning is undocumented/unspecified

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk



More information about the Gcc mailing list