C++/D class interop example crashes

Jan Jan at Krassnigg.de
Sat Mar 27 15:09:20 UTC 2021


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?

Also, if anyone here has contacts to the people that maintain the 
samples, maybe someone should adjust the sample to not contain 
code that may break this way.


More information about the Digitalmars-d-learn mailing list