Can't use a C++ class from a DLL

Artie apple2000 at mail.ru
Mon Oct 29 06:55:18 PDT 2012


>
> As all your functions are `APIENTRY`, write `extern(Windows):` 
> before them. And use `c_ulong` as analogue of `unsigned long`. 
> So full correct `IBank` interface declaration here:
> ---
> import core.stdc.config: c_ulong;
>
> extern(C++) interface IBank
> {
> extern(Windows):
>     const char* getLastError();
>     const char* getDetail(char* detail);
>     bool deposit(c_ulong number, double amount);
>     bool withdraw(c_ulong number, double amount);
>     double getBalance(c_ulong number);
>     bool transfer(c_ulong numberFrom, IBank* bankTo, c_ulong 
> numberTo, double amount);
>     bool transferAccept(IBank* bankFrom, c_ulong numberTo, 
> double amount);
> };
> ---

Thank you very much, Denis. It was quite confusing to mix 
extern(C++) and extern(Windows). And I also thank Jakob for 
syntax specification.

BTW, it's said in the ABI reference that `unsigned long` must be 
substituted with `uint`. And it seems to work fine for the data I 
used in the example.


More information about the Digitalmars-d mailing list