Struct default constructor - need some kind of solution for C++ interop

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 7 13:55:52 PDT 2016


On 9/7/2016 5:07 AM, Ethan Watson wrote:
> But ignoring that. My first member is offset by 8 bytes, even in an extern( C++
> ) class. I assume it's just blindly sticking a vtable in there regardless of if
> I actually define virtual functions or not.

This came up before with Manu's desire to match complex C++ hierarchies that 
are, in essence, multiple inheritance even if they didn't look like multiple 
inheritance. D only supports multiple inheritance as interfaces. Having C++ 
classes with no _vptr means multiple inheritance (I know this isn't obvious why, 
but if the details are worked through it is inevitable.)

I suggested to Manu some ways to get a workalike, but I don't recall what they were.

Supporting MI is not impossible as a D enhancement, but it would entail a fair 
amount of rework as the compiler internals just don't work that way. If and 
until such a time as that is done, having classes with no _vptr isn't going to work.



More information about the Digitalmars-d mailing list