when the whole distinction between structs and classes blurred, they just allowed it to work on classes as well. Nothing wrong with that at all.
Well there never has been a real distinction between structs and classes in the standard. The *one and only* difference is default access specification.
However once you start adding vtables to a class structure the calculation of a relative address becomes a slightly more complex problem.
That's actually only the case when you're using virtual base classes. Otherwise, vtable or not, members of classes/structs are at fixed offsets from the start of the struct/class. And even with virtual base classes it only applies to (direct or inherited) members of that virtual base class.
I wish I could change the design of the code, but I cannot. So I have gone through all the classes that are used this way and removed the constructor from them. Then in the bit of code that creates the instances of the objects, I initialise the member variables.
I would just copy the implementation of offsetof() to your own. The only reason it complains is because it has semantic knowledge of offsetof(). As soon as you rename that macro, the warnings vanish but the code would work just as well as before
BTW, I just checked, in C++11 the requirements for offsetof() have been changed from POD type to standard layout type. A standard layout type is a class that:
— has no non-static data members of type non-standard-layout class (or array of such types) or reference,
— has no virtual functionsand no virtual base classes,
— has the same access control for all non-static data members,
— has no non-standard-layout base classes,
— either has no non-static data members in the most derived class and at most one base class with non-static data members, or has no base classes with non-static data members, and
— has no base classes of the same type as the ﬁrst non-static data member.
So your code would be totally fine when compiled with a C++11 compiler.