Search code examples
c++windowsname-manglingname-decoration

Is C++ name mangling (decoration) deterministic?


I hope to LoadLibrary on an unmanaged C++ DLL with managed code, and then call GetProcAddress on extern functions which have been mangled. My question is are the mangled names you get from a C++ compiler deterministic? That is: Will the name always by converted to the same mangled name, if the original's signature hasn't changed?


Solution

  • It isn't specified by the standard, and has certainly changed between versions of the same compiler in my experience, though it has to be deterministic over some fixed set of circumstances, because otherwise there would be no way to link two separately compiled modules.

    If you're using GetProcAddress, it would be far cleaner to export the functions as extern "C" so their names are not mangled.