D-dll support: testers needed round 2
Rainer Schuetze
r.sagitario at gmx.de
Sat Mar 31 08:33:19 UTC 2018
On 21/03/2018 07:46, evilrat wrote:
> On Friday, 9 February 2018 at 20:34:33 UTC, Benjamin Thaut wrote:
>> My work on dll support for D continues. There is another iteration I
>> need help testing with.
>>
>> Getting started tutorial:
>> http://stuff.benjamin-thaut.de/D/getting_started.html
>>
>> A binary distribution is provided, see the tutorial for details.
>
> Played a bit with your binaries, here are some issues.
>
> Importing non-compiled modules works ok.
> However when doing manual library loading(both WinAPI LoadLibrary and
> Runtime.loadLibrary) things is the same as in vanilla DMD/LDC - casting
> not working.
>
> Classes(incl. abstract) works in a hacky way (first cast to void* - then
> to actual class), again same as plain DMD, no changes here.
>
> Interfaces doesn't work at all, doing the hack above on
> interface-derived object messes up vtbl/offsets, resulting in wrong
> function called.
>
> -import switch seems to do the trick, but how to deal with dynamic loading?
>
I guess you want to cast to a class that is only defined in the
dynamically loaded DLL? The problem is that casting needs a reference to
the class info of the target class which only exists in the referenced
DLL, which needs static DLL linkage.
One suggestion would be to export a common class/interface definition
from a DLL that is referenced by both the dynamic DLL and the loading
executable.
More information about the Digitalmars-d
mailing list