Am 27.05.2014 11:56, schrieb chmike:
Hello,

note that D is still very new to me.

The documentation for
http://dlang.org/phobos/core_runtime.html#.Runtime.loadLibrary is a bit
too terse to answer my question.

I would like to know if it would allow to use Object.factory() with the
classes defined in the loaded library and if the GC would manage data
allocated with new in the code of the library.

Does the loaded dll need to be defined as a module or something like that ?


No, DLL support on windows is very limited at the moment. Basically you can create D-DLLs which have a C-interface. Exporting anything but functions does not or only partially work.

The biggest problem on Windows is that there is no shared version of druntime/phobos. Which means you have to link a full version of druntime/phobos into each of your dlls. This not only increases binary size, it also leads to problems. E.g. if you create a phobos class in one dll and pass it to another you can no longer cast it (because the type infos exist twice). There are lot more fun problems, so I would advice against using DLLs for anything else then C-library like projects.

This DIP might give you a good overview of whats currently broken with DLLs: http://wiki.dlang.org/DIP45

Kind Regards
Benjamin Thaut

Reply via email to