Names of C functions exported from a dll

Martin Drašar drasar at ics.muni.cz
Mon Jan 2 13:32:32 PST 2012


Dne 2.1.2012 19:52, Martin Nowak napsal(a):
> Do you mean exported by dmd?
> AFAIK on Windows cdecl function names are prefixed with an underscore.

Yes, dmd v2.057

This code:
> import std.c.windows.windows;
> import core.sys.windows.dll;
>
> export extern (C) void fn1() {}
> export extern (C) void fn2() {}
> export extern (C) void fn3() {}
>
> extern (Windows)
> BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
> {
>     return true;
> }

gives this output in dependency walker:

> _fn1
> fn2
> fn3

whereas this C++ code:

> extern "C" _declspec(dllexport) int _cdecl fn1() { return 1; }
> extern "C" _declspec(dllexport) int _cdecl fn2() { return 1; }
> extern "C" _declspec(dllexport) int _cdecl fn3() { return 1; }

compiled with VS2008 gives this output in dependency walker:

> fn1
> fn2
> fn3

so I guess that cdecl does not necessary mean underscore in function name...

Martin


More information about the Digitalmars-d mailing list