This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: how to compute offset of data member at compile time (virtual class)


On Thu, 25 Oct 2007 17:57:11 +0100
Andrew Haley <aph-gcc@littlepinkcloud.COM> wrote:

> John Gateley writes:
>  > I need to compute the offset of a data member at compile time.
>  > The class has virtual functions, and so the offsetof macro does
>  > not work (why?).
> 
> Because it's a non-POD type.  See Section 9, Classes:
> 
>  > Is there a way to do this?
> 
> No.  Consider what happens with multiple and virtual inheritance.
> 

Thanks for the reply.

It seems to me that even with multiple
and virtual inheritance, the offset is a compile time constant.
It may be complex to determine it, but it doesn't change.

j
-- 
John Gateley <gateley@jriver.com>


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