Name-mangling is a technique used by compilers (mainly C++ compilers) to encode information in strings that can be supported by linkers designed to handle C code.
Questions relating to the schemes used for name mangling, linking problems in the face of mangling, or the tools used to decode mangled names (like c++filt or dem) are appropriate for this tag.
In C++, name mangling is used to encode things like the symbol's namespace and/or function signature.
For example, given this C++ code:
namespace Foo {
namespace Bar {
class A {
public:
A();
~A();
};
}
int f(int i)
{
Bar::A a;
}
int f(double d)
{
Bar::A a;
}
}
the g++ compiler on a Linux box might generate the following "mangled" names for the 2 overloads of f() and A's constructor and destructor:
- _ZN3Foo1fEd
- _ZN3Foo1fEi
- _ZN3Foo3Bar1AC1Ev
- _ZN3Foo3Bar1AD1Ev
Using a tool like c++filt, we can decode these names:
$ echo _ZN3Foo1fEd | c++filt
Foo::f(double)
$ echo _ZN3Foo3Bar1AC1Ev | c++filt
Foo::Bar::A::A()
Of course, if you're not using g++ on Linux, the mangled form for your symbols may (likely WILL) be different. (The C++ FAQ lite subtly suggests that if two C++ compilers have different ABIs, even in small details, then they should intentionally have different name mangling schemes, so that things break in an obvious way and not a subtle way.)