On Saturday, 27 March 2021 at 15:09:20 UTC, Jan wrote:
I just tried to get this example to work:
https://dlang.org/spec/cpp_interface.html#using_d_classes_from_cpp

It kept crashing for me with a 'privileged instruction' error when the function 'bar' was executed. Finally I removed the call to writefln and voilà it finally works.

So why does it fail? I assumed the standard library functions should all work. I'm compiling with "dmd -shared -m64 -debug" and link against a C++ DLL that was built with VS2019. Should the D DLL not contain everything to be self-sufficient to use it's entire runtime functionality?
And if not, what other functions might be problematic?

The example links objects statically. You may be experiencing additional challenges with crossing DLL boundaries. I have not yet used DLLs, but did you initialise the D runtime?

— Bastiaan.

Reply via email to