C++ linkage specifics WRT virtual vs non-virtual member functions

Roman Hargrave via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 13 00:18:31 PDT 2017


I'm writing some bindings and have run in to a dilemma due to the 
lack of explicit information on how the D compiler "decides" to 
use virtual dispatch for a member function or not.

Specifically, I have a C++ library that _explicitly_ marks some 
member functions as virtual, in addition to a plethora of 
non-virtual functions.

I would like to be certain that the D compiler understands that I 
would like it to treat those functions as virtual functions, but 
unlike C++ where there is a `virtual` classifier for functions, D 
does not appear to have such a facility.

The C++ interop documentation suggests that both non- and virtual 
functions are supported, but further suggests that it only treats 
inherited functions as virtual with no method of explicitly 
requesting virtual dispatch for that method.

As far as I can tell, all specified member functions in a class 
with C++ linkage are assumed to be non-virtual unless they are 
overriden?


More information about the Digitalmars-d mailing list