From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10949 invoked by alias); 23 Apr 2003 19:47:27 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 10855 invoked from network); 23 Apr 2003 19:47:24 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by sources.redhat.com with SMTP; 23 Apr 2003 19:47:24 -0000 Received: from fleche.redhat.com (tf0199.peakpeak.com [204.144.239.199]) by gash2.peakpeak.com (8.9.3/8.9.3.1) with ESMTP id NAA28851; Wed, 23 Apr 2003 13:47:08 -0600 Received: by fleche.redhat.com (Postfix, from userid 1000) id 623014F80D0; Wed, 23 Apr 2003 13:39:49 -0600 (MDT) To: Gabriel Dos Reis Cc: Jason Merrill , Jamie Lokier , Andrew Haley , gcc@gcc.gnu.org Subject: Re: On alignment References: <200303251122.13693.kevin.hendricks@sympatico.ca> <200303251344.59988.kevin.hendricks@sympatico.ca> <16037.6826.35777.756256@cuddles.redhat.com> <20030423124944.GA24593@mail.jlokier.co.uk> <87wuhlgq5l.fsf@fleche.redhat.com> <87lly1f5ir.fsf@fleche.redhat.com> From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom X-Zippy: Where do your SOCKS go when you lose them in th' WASHER? Date: Wed, 23 Apr 2003 20:23:00 -0000 In-Reply-To: Message-ID: <87sms9dmuy.fsf@fleche.redhat.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-04/txt/msg01183.txt.bz2 >>>>> "Gabriel" == Gabriel Dos Reis writes: Gabriel> #define FIELD_ALIGNOF(TYPE) __alignof (((struct { TYPE t; } *)0)->t) Gabriel> j.C: In function `int main()': Gabriel> j.C:7: error: types may not be defined in casts I got that too, but I worked around it like so: template struct aligner { T field; }; #define ALIGNOF(TYPE) (__alignof__ (((aligner *) 0)->field)) Gabriel> I think the template-based solution I posted in another Gabriel> message solves the problem... In that message you said that you got "8" as the answer for a double field on x86. That's not the answer I'm looking for :-(. On x86, a double field has alignment 4, while a non-field double has alignment 8. In the libgcj context, we're only ever laying out structures, so we need to get "4" as the answer. The above does do that. Tom