Name Mangling in C++

So, dog days are going here in Gwalior, but it doesn't feel that much at home obviously, I wonder how it would be to sit in college in such a hot weather and then returning to home getting fried by the inevitable flames of the Sun, sounds tortous to me at least, but it's any port in a storm so we can't complain. 
Coming to the topic for the day. "Name mangling", to be honest I heard about this topic a few days ago only, in Geeks for Geeks official website's C++ documentation, they have a whole list of topics for most of the languages, it's very helpful in my opinion. Again coming back to the topic, name mangling basically refers to the compiler adding additional information to the names of the functions with the same names to differ between them. 
For this, you must have knowledge about what is "Function Overloading", in this we make more than one function with the same name but with different parameters. But the question arises that how the compiler differs between them. So, actually the compiler mangles the names of the functions included in function overloading, it adds information about the parameters to the  name, there isn't any specific rule for name mangling but, basically most of the compilers mangles the names in this manner, for example, if a function if there:- 
void greet(int n,string str){//definition}, and another function, 
void greet(string str){//definition} 
So, most of the compiler will change the name of the second function implicitly to
void __greet__s(string str){//definition}.
This was all about "Name Mangling" in C++.

Comments

Popular Posts