This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Postioning of items within a class
- To: rth at cygnus dot com (Richard Henderson)
- Subject: Re: Postioning of items within a class
- From: Joe Buck <jbuck at racerx dot synopsys dot com>
- Date: Wed, 12 Jul 2000 17:03:45 -0700 (PDT)
- Cc: prometheus at lokigames dot com (Andrew Henderson), gcc at gcc dot gnu dot org
> > 2. Failing that, is there a GCC way of querying the class and getting
> > the offsets of members within the class (perhaps an __attribute__ of
> > some sort)?
>
> There's offsetof, but that may only work for POD structures in C++.
> I don't know for sure.
ISO C++ promises only that offsetof works for PODs.
In practice a larger number of cases should work just fine; for the
cases that don't (e.g. virtual base classes) the concept of an offset
is fuzzy anyway.
(Sure hope the guy whose code you're porting didn't drop to assembly just
because he didn't know about offsetof).