This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Postioning of items within a class


> > 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).



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]