[Issue 18845] New: Extern(C++) class with no virtual functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 9 21:10:50 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18845
Issue ID: 18845
Summary: Extern(C++) class with no virtual functions
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
I just encountered a gotcha where D doesn't support extern(C++) classes with no
vtable.
In C++, if a class has no virtual functions, there is no vtable.
If a virtual is added to a derived class, the vtable is pre-pended to the base.
Is it possible to replicate this in extern(C++)?
We have had a bunch of gotchas related to this.
You can argue that a base class with no virtual functions is a struct, and that
may be true, except that its *intent* is that it shall be derived from. D can
not derive a class from a struct, so the base-with-no-virtuals needs to be
expressed as a class in D for the arrangement to translate and interact with D
code.
--
More information about the Digitalmars-d-bugs
mailing list