I've been reading the D Cookbook and near the beginning there's the following sentence:
D is binary compatible with C, but not source compatible.
SAS allows users to define and call C functions from within SAS. But I'm wondering, would it'd also be possible to do this from D?
I found Adam Ruppe's answer to create a DLL here, and I tried using that to create the DLL example from the SAS documentation; however, whenever I go to call it, the dll gets loaded, and then SAS proceeds to crash (without any crash log that I can find).
Yes, you can write DLLs in D which use or implement a C API.
You have to make sure that the function signatures and calling conventions match. In the page you linked, the calling convention is indicated as stdcall
, so your D functions need to be annotated with extern(Windows)
or extern(System)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With