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

sighoya sighoya at gmail.com
Mon May 24 20:31:18 UTC 2021


On Monday, 24 May 2021 at 17:39:38 UTC, Gavin Ray wrote:
> 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.

I think classes annotated with extern is your only high level 
guaranteed == type safe option to be compatible to other c++ 
classes.

But you seek for the general multiple inheritance case which 
seems not to be supported with `extern`, sadly.
So you stick with manual solutions like template metaprogramming 
or/and raw pointer fiddling.
Anyway, both solutions would require an unsafe cast in the end, 
so you are on your own.





More information about the Digitalmars-d-learn mailing list