Search code examples
dllexportdname-mangling

Exported function symbol name mangling


I have a D DLL that is being loaded by a C++ program that I have no control over. The program LoadLibrarys my DLL and uses GetProcAddress to find a function named "extension_load" that takes one argument (a pointer). In my D DLL I have:

extern (C) int extension_load(void* ptr) {
    return 0;
}

And this name needs to be exported as extension_load but it is being exported as extension_load@4, so GetProcAddress cannot find it. How do I make it plain extension_load without the name mangling?


Solution

  • You'll need to provide the linker with a .def file that renames the export. Docs are here, you need EXPORTS.