what exactly meaning of name mangling? why it is occurred?

Hello!

Just wondering why exactly name mangling is required? and what cause it to occur?

Can anybody explain in brief what this concept all about?

Thanks!
..what cause it to occur?

The compiler linker causes name mangling\name decoration (It's the same thing, you'll see the terms used interchangeably so I'll get that potential confusion out of the way now).

...why exactly name mangling is required?

For a number of reasons. One of them is so that you and I can enjoy the convenience of 'using' namespaces to save ourselves some typing without confusing the poor compiler about which function you are actually calling. Also so that we can reuse the same function names, again without confusing the compiler.

Name mangling is the process in which descriptive data is added to a functions identifier at link time. This data indicates which namespace and object (if any) a function belongs to, along with the arguments that it is designed to handle and the order in which those arguments should be passed. This was originally done because C++ "compilers" at first were more accurately described as a C++ to C translators and so for the code to be usable functions could not share the same names and namespaces had to be turned into something else. Now we have true C++ compilers but they've become so integrated with other tools that were originally developed to work with C, that the practice continues. This also has the benefit of making C++ code inter-operable with code written in C.
Topic archived. No new replies allowed.