Monday, February 27, 2012

What is name mangling?

Name mangling is a process of creating the encoded unique function name with the function name and parameters, so that linker will identify the functions. This will be usefull for the solving the conflicts for the same function name and variables.  Name mangling is also called Name decoration.
     Name mangling is depends on the compiler. It is not same for all compilers.In C++, it will be used in function overloading, and for same variable names in differnt name spaces. Some C compilers also uses name mangling to variables.

void display()
    // some code

int display(int a)
    //some code


In the above code actual function name is display() with overloading definitions. the curresponding name mangling names are given below.

actual name : display()             mangled name: _Z7displayv
actual name : display(int a)       mangled name: _Z7displayi

No comments:

Popular Posts