This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On alignment
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: tromey at redhat dot com
- Cc: Andrew Haley <aph at redhat dot com>, Jason Merrill <jason at redhat dot com>, Jamie Lokier <jamie at shareable dot org>, gcc at gcc dot gnu dot org
- Date: 02 May 2003 15:07:54 +0200
- Subject: Re: On alignment
- Organization: Integrable Solutions
- References: <200303251122.13693.kevin.hendricks@sympatico.ca><wvl1y0vmhdv.fsf@prospero.boston.redhat.com><wvlu1drl2kl.fsf@prospero.boston.redhat.com><200303251344.59988.kevin.hendricks@sympatico.ca><wvlhe9rkzgm.fsf@prospero.boston.redhat.com><16037.6826.35777.756256@cuddles.redhat.com><jen0ii4x27.fsf@sykes.suse.de><20030423124944.GA24593@mail.jlokier.co.uk><87wuhlgq5l.fsf@fleche.redhat.com><wvlu1cpdv7s.fsf@prospero.boston.redhat.com><87lly1f5ir.fsf@fleche.redhat.com><wvllly1dq6q.fsf@prospero.boston.redhat.com><m3ist5auzc.fsf@uniton.integrable-solutions.net><87sms9dmuy.fsf@fleche.redhat.com><wvlptncd0i2.fsf@prospero.boston.redhat.com><16039.44856.826662.680167@cuddles.redhat.com><87znm6utca.fsf@fleche.redhat.com>
Tom Tromey <tromey@redhat.com> writes:
[...]
| What will eventually go wrong with what we have now?
|
| template<typename T>
| struct aligner
| {
| T field;
| };
|
| #define ALIGNOF(TYPE) (__alignof__ (((aligner<TYPE> *) 0)->field))
This, as I understand it from my previous attempt, won't give you the
right answer (for double, it would give 8 instead of 4).
What is wrong with the following code I posted earlier?
template<typename T>
struct alignment {
struct helper {
T datum;
helper();
};
static helper instance;
enum { value = __alignof__ (instance) };
};
-- Gaby