extern(C++): override nonvirtual member function

sfp sfp at hush.ai
Thu Apr 24 19:41:48 UTC 2025


I'm trying to wrap some C++ classes, and one issue I've run into 
is having an extern(C++) class inheriting from another, with the 
child doing a "nonvirtual override" of a nonvirtual member 
function in the base class... E.g., in C++:
```
struct A {
   void f() { ... }
   ...
   // some other virtual functions
};

struct B {
   void f() { ... } // nonvirtual override A::f
   ...
   // other VFs
};
```
D doesn't seem to like this very much... Is there some way to 
hack around this issue? For a variety of reasons, I can't make 
any modifications to the C++ code I'm wrapping.

For more context, I'm writing a script that's generating wrappers 
for about 150 header files, maybe 100-200k LOC (using the 
cxxheaderparse Python library). This is actually going pretty 
well, but he best solution I can come up with right now is to try 
to detect cases like this and omit them, but it's less than 
ideal. The C++ library is mostly C++98 style and it's been smooth 
sailing with the occasional wart I've needed to figure out like 
this.


More information about the Digitalmars-d-learn mailing list