Calling D from C++

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Jul 18 20:52:05 PDT 2011


On 7/19/11, Johann MacDonagh <johann.macdonagh.no at spam.gmail.com> wrote:
> If you export it like this, it will be exported as the C++ mangled name.
> If you have extern(C) it will be cdecl "_SetInt" and extern(Windows)
> will be stdcall "_SetInt at 4".

Right, that's all pretty standard stuff. :)

>
>> I don't know why, but if you use a .def file instead of `export` the
>> function will be exported as a C function with no name mangling.
>
> If you look at dumpbin /exports you'll see something like this:
>
>      ordinal hint RVA      name
>
>            1    0 0000306C SetInt = ?SetInt@@YAXPAH at Z (void __cdecl
> SetInt(int *))
>
> So the symbol still has C++ name mangling but its exported as whatever
> name you want.
>

See I tried using dumpbin, but apparently I wiped it from my PATH so I
had to rely on DLL Export viewer (because I'm lazy and it had an icon
on my desktop!) which doesn't even show this. I had a hunch that was
happening behind the scenes. Thanks for the info regardless hehe.


More information about the Digitalmars-d-learn mailing list