Optional name mangling
Daniel Murphy
yebblies at nospamgmail.com
Sat Jul 21 23:45:16 PDT 2012
"Stuart" <stugol at gmx.com> wrote in message
news:hmapfdehxvvuuxswrtyb at forum.dlang.org...
> Hi. Is there any way to instruct the D compiler not to use name mangling
> when referencing an external C++ function?
>
> For example:
>
> extern (System) bool PathRenameExtension(LPSTR pszPath, LPCSTR pszExt);
>
> In this particular case, the exported function being referenced is not
> called _PathRenameExtension at 8 - it's just called PathRenameExtension. Now,
> it's great that D helpfully mangles the name for me when appropriate, but
> we really need some way to disable it when necessary.
>
> Is there any way to import this function without creating a .def file with
> "_PathRenameExtension at 8 = PathRenameExtension"? And if not, why not?
The problem isn't that D is mangling names it shouldn't, the problem is that
your import library uses the wrong mangling for the internal names of
imported symbols. Using the .def file with implib is the correct solution,
unless you want to try converting a coff import library to omf (I've never
got that to work). The reason implib needs a def file to work correctly is
because only the exported name is stored in the dll, not the mangled name.
More information about the Digitalmars-d
mailing list