We all know that many languages support function overloading, so how does the compiler handle naming conflicts after compiling them?
1, first give a few correct overloaded functions:
#include <iostream>using namespace STD;intADD (intAintb) {returnA + b;}DoubleADD (DoubleADoubleb) {returnA + b;}DoubleADD (DoubleAintb) {returnA + b;}DoubleADD (intADoubleb) {returnA + b;}voidADD (void){ ;}intMain () {intA =Ten;intb = -;DoubleD1 =1.0;DoubleD2 =2.0; Add (A, b); ADD (D1, D2);return 0;}
2. View the method of new name of overloaded function after compiling
A. Under VS2010, the overloaded functions are masked directly, and then in the main function call these functions, the error will be given at this time, we will see the errors in the message of the new names of these functions. This method is relatively simple.
B. Under vs2013, first right-click your project in the solution (the compiler interface does not have a solution that can be recalled in the following ways: Tap View, Solution Explorer or direct CTRL+ALT+L), and then click: Properties---Configuration Properties-- > Debug, find the Map Export column, change the default to: Yes (/mapinfo:exports), then recompile the program. At this point, find the location of your project (the physical location on your computer's hard drive), locate the file with the suffix. Map in the Debug folder, open it with Notepad or other document browsing software, and, in the form of edit-and-find, enter your overloaded function name, search, Until you find a few contiguous new function names that are similar to the names of the original functions, these are your new function names.
C. Disassemble the compiled file under Linux to view
① create a. cpp file and copy the code in
② compiling the file
③ executes the command objdump-d a.out >log.txt disassembly and redirects the result to the Log.txt file.
④ generates an Log.txt file for analysis.
We can see that the name of the overloaded function in the log.txt becomes the corresponding ones, and it is obvious that the new name of the overloaded function in Linux can be clearly seen after disassembly.
And we can sum up the law of the new name that the overloaded function appears after disassembly (Z3 right here is a scope identifier):
Scope + function name + first letter of parameter list parameter type
The new name after the overloaded function is compiled