Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
If I declare a function as extern(C) inside a DLL, I have also to cast the function pointer as extern(C) or it fails calling, eg. ```d // --- my.dll export extern (C) void log(int mode, string a, string b, string c) { /* stuff */ } // --- main.d alias T = extern (C) void function(int, strin

Re: Linkage question

2022-01-24 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 24 January 2022 at 17:23:01 UTC, frame wrote: I understand that the linkage must match but besides the name mangling, what's happen here? What is the difference if I remove the `extern (C)` part from the T alias? The difference is in how arguments are being passed, which you seem

Re: Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov wrote: The difference is in how arguments are being passed, which you seem to have discovered already :) Would like to know where the linkage format is defined, thx. It should be here: https://dlang.org/spec/abi.html although II

Re: Linkage question

2022-01-24 Thread Paul Backus via Digitalmars-d-learn
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote: It claims that the D calling convention matches C. But it seems that the arguments are pushed in order whereas C does it in reverse order and the -218697648 value is indeed my 3rd string pointer. Windows has two calling conventions for

Re: Linkage question

2022-01-24 Thread duser via Digitalmars-d-learn
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote: On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov wrote: The difference is in how arguments are being passed, which you seem to have discovered already :) Would like to know where the linkage format is defined, thx. It sh