Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 941
Blanthor Avatar asked Jul 15 '10 06:07

Blanthor


People also ask

Is C++ name mangling deterministic?

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.

Does C use name mangling?

Since C is a programming language that does not support name function overloading, it does no name mangling.

What is mean by name mangling naming decoration?

Name mangling is the encoding of function and variable names into unique names so that linkers can separate common names in the language. Type names may also be mangled. Name mangling is commonly used to facilitate the overloading feature and visibility within different scopes.

Is C++ name mangling standardized?

The C++ standard therefore does not attempt to standardize name mangling.


1 Answers

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.

like image 56
Daniel Earwicker Avatar answered Sep 18 '22 15:09

Daniel Earwicker