views:

615

answers:

6

How do I view the compiler-generated mangled names for overloaded functions in C++? I'm using VC9 but answers for other compilers are welcome too.

Edit: I find all the answers useful here. Accepting the one I liked best.

+4  A: 

You can view decorated (mangled) names with Dumpbin.

JP Alioto
+4  A: 

You could look in the map file. Assuming you have map file generation turned on.

Simeon Pilgrim
What if you have multiple overloads of the same function?
Ofek Shilon
Then you will see many functions with the same name wrapped in different mangled forms, for each overload.
Simeon Pilgrim
Well you will then see multiple version of that function with each of there mangled names forms. Thus the purpose of name mangling, to avoid name conflicts.
Simeon Pilgrim
+6  A: 

You can see the decorated function names by using Dependency Walker.

Open any DLL\EXE in dependency walker and in right pane you can see a list of decorated function names.

aJ
+4  A: 

Since you also ask about other compilers. There is a tool called nm on the gnu toolchain. You will get it on linux and cygwin, and I believe that it is also available in mingw. Calling it with no parameters will show the mangled symbols in the binary. Calling it with --demangle will do the obvious.

David Rodríguez - dribeas
+2  A: 

look at similar question answered recently

http://stackoverflow.com/questions/733056/is-there-a-way-to-get-function-name-inside-a-c-function

RED SOFT ADAIR
+1  A: 

While all the above works, there is a nicely documented way to view the mangled names by use of Listing Files: Project Property Pages -> C/C++ -> Output Files -> Assembler Output.

(EDIT:)

There is a reason only Listing files and DUMPBIN are documented as ways to see decorated names. Both the map file and dependency walker, suggested as solutions, display only decorated names. If you have multiple overloads of a function name, you'll have a hard time matching them to the various decorated names you'd see. (That's more or less reconstructing the decoration scheme. While possible, it defeats the whole original purpose.)

Ofek Shilon