How does inheritance and vtables work wrt. C++ and interop with D? Fns w/ Multiple-inheritance args impossible to bind to?

Gavin Ray gavinray at site.com
Mon May 24 17:39:38 UTC 2021


On Sunday, 23 May 2021 at 21:08:06 UTC, Ola Fosheim Grostad wrote:
> On Sunday, 23 May 2021 at 21:02:31 UTC, Gavin Ray wrote:
>> I don't really know anything at all about compilers or 
>> low-level code -- but is there any high-level notion of 
>> "inheritance" after it's been compiled?
>
> Yes, in the structure of the vtable, which is why the spec is 
> so hard to read.
>
> If possible stick to single inheritance in C++...

Yeah agreed, multiple inheritance is asking for trouble.

But unfortunately when you're binding to existing libraries you 
don't have control over the API

Hence why I was asking how to make D structs/classes that have 
compatible or identical vtables to multiply inherited objects to 
pass as arguments to `extern (C++)` functions.

Also general explanation of what makes a compiled variable 
compatible in terms of vtable with what's expected as an argument

I'd be grateful for solid information on this


More information about the Digitalmars-d-learn mailing list