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, string, string, string);
auto fnPtr = cast(T)GetProcAddress(/* stuff */);
```

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?

Doing that supplies 2nd and 3rd paramter as fine pointers but the 1st argument comes wrong (eg. 10 becomes -218697648) and the last argument is garbage too, so the D-linkage format is something different.

Would like to know where the linkage format is defined, thx.

Reply via email to