<s>
In	O
compiler	B-Language
construction	O
,	O
name	B-Language
mangling	I-Language
(	O
also	O
called	O
name	B-Language
decoration	I-Language
)	O
is	O
a	O
technique	O
used	O
to	O
solve	O
various	O
problems	O
caused	O
by	O
the	O
need	O
to	O
resolve	O
unique	O
names	O
for	O
programming	O
entities	O
in	O
many	O
modern	O
programming	O
languages	O
.	O
</s>
<s>
It	O
provides	O
a	O
way	O
of	O
encoding	O
additional	O
information	O
in	O
the	O
name	O
of	O
a	O
function	B-Language
,	O
structure	O
,	O
class	O
or	O
another	O
datatype	O
in	O
order	O
to	O
pass	O
more	O
semantic	O
information	O
from	O
the	O
compiler	B-Language
to	O
the	O
linker	B-Application
.	O
</s>
<s>
The	O
need	O
for	O
name	B-Language
mangling	I-Language
arises	O
where	O
the	O
language	O
allows	O
different	O
entities	O
to	O
be	O
named	O
with	O
the	O
same	O
identifier	O
as	O
long	O
as	O
they	O
occupy	O
a	O
different	O
namespace	O
(	O
typically	O
defined	O
by	O
a	O
module	B-Architecture
,	O
class	O
,	O
or	O
explicit	O
namespace	O
directive	O
)	O
or	O
have	O
different	O
signatures	O
(	O
such	O
as	O
in	O
function	B-Language
overloading	I-Language
)	O
.	O
</s>
<s>
Any	O
object	B-Language
code	I-Language
produced	O
by	O
compilers	B-Language
is	O
usually	O
linked	O
with	O
other	O
pieces	O
of	O
object	B-Language
code	I-Language
(	O
produced	O
by	O
the	O
same	O
or	O
another	O
compiler	B-Language
)	O
by	O
a	O
type	O
of	O
program	O
called	O
a	O
linker	B-Application
.	O
</s>
<s>
The	O
linker	B-Application
needs	O
a	O
great	O
deal	O
of	O
information	O
on	O
each	O
program	O
entity	O
.	O
</s>
<s>
For	O
example	O
,	O
to	O
correctly	O
link	O
a	O
function	B-Language
it	O
needs	O
its	O
name	O
,	O
the	O
number	O
of	O
arguments	O
and	O
their	O
types	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
The	O
simple	O
programming	O
languages	O
of	O
the	O
1970s	O
,	O
like	O
C	B-Language
,	O
only	O
distinguished	O
subroutines	O
by	O
their	O
name	O
,	O
ignoring	O
other	O
information	O
including	O
parameter	O
and	O
return	O
types	O
.	O
</s>
<s>
Later	O
programming	O
languages	O
,	O
like	O
C++	B-Language
,	O
defined	O
stricter	O
requirements	O
for	O
routines	O
to	O
be	O
considered	O
"	O
equal	O
"	O
,	O
such	O
as	O
the	O
parameter	O
types	O
,	O
return	O
type	O
,	O
and	O
calling	O
convention	O
of	O
a	O
function	B-Language
.	O
</s>
<s>
These	O
requirements	O
enable	O
method	B-Language
overloading	I-Language
and	O
detection	O
of	O
some	O
bugs	O
(	O
such	O
as	O
using	O
different	O
definitions	O
of	O
a	O
function	B-Language
when	O
compiling	B-Language
different	O
source	O
files	O
)	O
.	O
</s>
<s>
These	O
stricter	O
requirements	O
needed	O
to	O
work	O
with	O
existing	O
tools	O
and	O
conventions	O
;	O
therefore	O
,	O
additional	O
requirements	O
were	O
encoded	O
in	O
the	O
name	O
of	O
the	O
symbol	O
,	O
since	O
that	O
was	O
the	O
only	O
information	O
the	O
traditional	O
linker	B-Application
had	O
about	O
a	O
symbol	O
.	O
</s>
<s>
Another	O
use	O
of	O
name	B-Language
mangling	I-Language
is	O
for	O
detecting	O
additional	O
non-signature	O
related	O
changes	O
,	O
such	O
as	O
function	B-Language
purity	O
,	O
or	O
whether	O
it	O
can	O
potentially	O
throw	O
an	O
exception	O
or	O
trigger	O
garbage	O
collection	O
.	O
</s>
<s>
An	O
example	O
of	O
a	O
language	O
doing	O
this	O
is	O
D	B-Application
.	O
These	O
are	O
more	O
of	O
a	O
simplified	O
error	O
checking	O
.	O
</s>
<s>
For	O
example	O
,	O
functions	O
and	O
could	O
be	O
compiled	B-Language
into	O
one	O
object	O
file	O
,	O
but	O
then	O
their	O
signatures	O
changed	O
to	O
and	O
used	O
to	O
compile	B-Language
other	O
source	O
calling	O
it	O
.	O
</s>
<s>
At	O
link	O
time	O
the	O
linker	B-Application
will	O
detect	O
there	O
is	O
no	O
function	B-Language
and	O
return	O
an	O
error	O
.	O
</s>
<s>
Similarly	O
,	O
the	O
linker	B-Application
will	O
not	O
be	O
able	O
to	O
detect	O
that	O
the	O
return	O
type	O
of	O
is	O
different	O
,	O
and	O
return	O
an	O
error	O
.	O
</s>
<s>
For	O
example	O
,	O
it	O
does	O
n't	O
fully	O
prevent	O
errors	O
like	O
changes	O
of	O
data	O
members	O
of	O
a	O
struct	B-Application
or	O
class	O
.	O
</s>
<s>
For	O
example	O
,	O
could	O
be	O
compiled	B-Language
into	O
one	O
object	O
file	O
,	O
then	O
the	O
definition	O
for	O
changed	O
to	O
be	O
and	O
used	O
in	O
the	O
compilation	B-Language
of	O
a	O
call	O
to	O
.	O
</s>
<s>
In	O
such	O
cases	O
,	O
the	O
compiler	B-Language
will	O
usually	O
use	O
a	O
different	O
calling	O
convention	O
,	O
but	O
in	O
both	O
cases	O
will	O
mangle	O
to	O
the	O
same	O
name	O
,	O
so	O
the	O
linker	B-Application
will	O
not	O
detect	O
this	O
problem	O
,	O
and	O
the	O
result	O
will	O
usually	O
be	O
a	O
crash	O
or	O
data	O
-	O
or	O
memory	O
corruption	O
at	O
runtime	O
.	O
</s>
<s>
Although	O
name	B-Language
mangling	I-Language
is	O
not	O
generally	O
required	O
or	O
used	O
by	O
languages	O
that	O
do	O
not	O
support	O
function	B-Language
overloading	I-Language
,	O
like	O
C	B-Language
and	O
classic	O
Pascal	B-Application
,	O
they	O
use	O
it	O
in	O
some	O
cases	O
to	O
provide	O
additional	O
information	O
about	O
a	O
function	B-Language
.	O
</s>
<s>
For	O
example	O
,	O
compilers	B-Language
targeted	O
at	O
Microsoft	O
Windows	O
platforms	O
support	O
a	O
variety	O
of	O
calling	O
conventions	O
,	O
which	O
determine	O
the	O
manner	O
in	O
which	O
parameters	O
are	O
sent	O
to	O
subroutines	O
and	O
results	O
are	O
returned	O
.	O
</s>
<s>
Because	O
the	O
different	O
calling	O
conventions	O
are	O
incompatible	O
with	O
one	O
another	O
,	O
compilers	B-Language
mangle	O
symbols	O
with	O
codes	O
detailing	O
which	O
convention	O
should	O
be	O
used	O
to	O
call	O
the	O
specific	O
routine	O
.	O
</s>
<s>
The	O
mangling	O
scheme	O
was	O
established	O
by	O
Microsoft	O
and	O
has	O
been	O
informally	O
followed	O
by	O
other	O
compilers	B-Language
including	O
Digital	B-Language
Mars	I-Language
,	O
Borland	O
,	O
and	O
GNU	B-Application
GCC	I-Application
when	O
compiling	B-Language
code	O
for	O
the	O
Windows	O
platforms	O
.	O
</s>
<s>
The	O
scheme	O
even	O
applies	O
to	O
other	O
languages	O
,	O
such	O
as	O
Pascal	B-Application
,	O
D	B-Application
,	O
Delphi	B-Language
,	O
Fortran	B-Application
,	O
and	O
C#	B-Application
.	O
</s>
<s>
When	O
compiling	B-Language
the	O
following	O
C	B-Language
examples	O
:	O
</s>
<s>
32	O
bit	O
compilers	B-Language
emit	O
,	O
respectively	O
:	O
</s>
<s>
In	O
the	O
and	O
mangling	O
schemes	O
,	O
the	O
function	B-Language
is	O
encoded	O
as	O
_@	O
and	O
@@	O
respectively	O
,	O
where	O
is	O
the	O
number	O
of	O
bytes	O
,	O
in	O
decimal	O
,	O
of	O
the	O
argument(s )	O
in	O
the	O
parameter	O
list	O
(	O
including	O
those	O
passed	O
in	O
registers	O
,	O
for	O
fastcall	O
)	O
.	O
</s>
<s>
In	O
the	O
case	O
of	O
,	O
the	O
function	B-Language
name	O
is	O
merely	O
prefixed	O
by	O
an	O
underscore	O
.	O
</s>
<s>
The	O
64-bit	O
convention	O
on	O
Windows	O
(	O
Microsoft	O
C	B-Language
)	O
has	O
no	O
leading	O
underscore	O
.	O
</s>
<s>
For	O
example	O
,	O
Fortran	B-Application
code	O
can	O
use	O
'	O
alias	O
 '	O
to	O
link	O
against	O
a	O
C	B-Language
method	O
by	O
name	O
as	O
follows	O
:	O
</s>
<s>
This	O
will	O
compile	B-Language
and	O
link	O
fine	O
under	O
32	O
bits	O
,	O
but	O
generate	O
an	O
unresolved	O
external	O
_f	O
under	O
64	O
bits	O
.	O
</s>
<s>
One	O
workaround	O
for	O
this	O
is	O
not	O
to	O
use	O
'	O
alias	O
 '	O
at	O
all	O
(	O
in	O
which	O
the	O
method	B-Language
names	I-Language
typically	O
need	O
to	O
be	O
capitalized	O
in	O
C	B-Language
and	O
Fortran	B-Application
)	O
.	O
</s>
<s>
In	O
C	B-Language
,	O
most	O
compilers	B-Language
also	O
mangle	O
static	B-Language
functions	I-Language
and	O
variables	O
(	O
and	O
in	O
C++	B-Language
functions	O
and	O
variables	O
declared	O
static	O
or	O
put	O
in	O
the	O
anonymous	O
namespace	O
)	O
in	O
translation	O
units	O
using	O
the	O
same	O
mangling	O
rules	O
as	O
for	O
their	O
non-static	O
versions	O
.	O
</s>
<s>
If	O
functions	O
with	O
the	O
same	O
name	O
(	O
and	O
parameters	O
for	O
C++	B-Language
)	O
are	O
also	O
defined	O
and	O
used	O
in	O
different	O
translation	O
units	O
,	O
it	O
will	O
also	O
mangle	O
to	O
the	O
same	O
name	O
,	O
potentially	O
leading	O
to	O
a	O
clash	O
.	O
</s>
<s>
Compilers	B-Language
are	O
usually	O
free	O
to	O
emit	O
arbitrary	O
mangling	O
for	O
these	O
functions	O
,	O
because	O
it	O
is	O
illegal	O
to	O
access	O
these	O
from	O
other	O
translation	O
units	O
directly	O
,	O
so	O
they	O
will	O
never	O
need	O
linking	B-Application
between	O
different	O
object	B-Language
code	I-Language
(	O
linking	B-Application
of	O
them	O
is	O
never	O
needed	O
)	O
.	O
</s>
<s>
To	O
prevent	O
linking	B-Application
conflicts	O
,	O
compilers	B-Language
will	O
use	O
standard	O
mangling	O
,	O
but	O
will	O
use	O
so-called	O
'	O
local	O
 '	O
symbols	O
.	O
</s>
<s>
When	O
linking	B-Application
many	O
such	O
translation	O
units	O
there	O
might	O
be	O
multiple	O
definitions	O
of	O
a	O
function	B-Language
with	O
the	O
same	O
name	O
,	O
but	O
resulting	O
code	O
will	O
only	O
call	O
one	O
or	O
another	O
depending	O
on	O
which	O
translation	O
unit	O
it	O
came	O
from	O
.	O
</s>
<s>
This	O
is	O
usually	O
done	O
using	O
the	O
relocation	B-Library
mechanism	O
.	O
</s>
<s>
C++	B-Language
compilers	B-Language
are	O
the	O
most	O
widespread	O
users	O
of	O
name	B-Language
mangling	I-Language
.	O
</s>
<s>
The	O
first	O
C++	B-Language
compilers	B-Language
were	O
implemented	O
as	O
translators	O
to	O
C	B-Language
source	O
code	O
,	O
which	O
would	O
then	O
be	O
compiled	B-Language
by	O
a	O
C	B-Language
compiler	B-Language
to	O
object	B-Language
code	I-Language
;	O
because	O
of	O
this	O
,	O
symbol	O
names	O
had	O
to	O
conform	O
to	O
C	B-Language
identifier	O
rules	O
.	O
</s>
<s>
Even	O
later	O
,	O
with	O
the	O
emergence	O
of	O
compilers	B-Language
that	O
produced	O
machine	O
code	O
or	O
assembly	O
directly	O
,	O
the	O
system	O
's	O
linker	B-Application
generally	O
did	O
not	O
support	O
C++	B-Language
symbols	O
,	O
and	O
mangling	O
was	O
still	O
required	O
.	O
</s>
<s>
The	O
C++	B-Language
language	I-Language
does	O
not	O
define	O
a	O
standard	O
decoration	O
scheme	O
,	O
so	O
each	O
compiler	B-Language
uses	O
its	O
own	O
.	O
</s>
<s>
C++	B-Language
also	O
has	O
complex	O
language	O
features	O
,	O
such	O
as	O
classes	B-Application
,	O
templates	B-Application
,	O
namespaces	O
,	O
and	O
operator	O
overloading	B-Application
,	O
that	O
alter	O
the	O
meaning	O
of	O
specific	O
symbols	O
based	O
on	O
context	O
or	O
usage	O
.	O
</s>
<s>
Because	O
the	O
name-mangling	O
systems	O
for	O
such	O
features	O
are	O
not	O
standardized	O
across	O
compilers	B-Language
,	O
few	O
linkers	B-Application
can	O
link	O
object	B-Language
code	I-Language
that	O
was	O
produced	O
by	O
different	O
compilers	B-Language
.	O
</s>
<s>
A	O
single	O
C++	B-Language
translation	O
unit	O
might	O
define	O
two	O
functions	O
named	O
:	O
</s>
<s>
The	O
C++	B-Language
compiler	B-Language
will	O
therefore	O
encode	O
the	O
type	O
information	O
in	O
the	O
symbol	O
name	O
,	O
the	O
result	O
being	O
something	O
resembling	O
:	O
</s>
<s>
Even	O
though	O
its	O
name	O
is	O
unique	O
,	O
is	O
still	O
mangled	O
:	O
name	B-Language
mangling	I-Language
applies	O
to	O
all	O
C++	B-Language
symbols	O
(	O
those	O
not	O
in	O
an	O
block	O
)	O
.	O
</s>
<s>
The	O
mangled	O
symbols	O
in	O
this	O
example	O
,	O
in	O
the	O
comments	O
below	O
the	O
respective	O
identifier	O
name	O
,	O
are	O
those	O
produced	O
by	O
the	O
GNU	B-Application
GCC	I-Application
3.x	O
compilers	B-Language
,	O
according	O
to	O
the	O
IA-64	O
(	O
Itanium	O
)	O
ABI	B-Operating_System
:	O
</s>
<s>
All	O
mangled	O
symbols	O
begin	O
with	O
(	O
note	O
that	O
an	O
identifier	O
beginning	O
with	O
an	O
underscore	O
followed	O
by	O
a	O
capital	O
letter	O
is	O
a	O
reserved	O
identifier	O
in	O
C	B-Language
,	O
so	O
conflict	O
with	O
user	O
identifiers	O
is	O
avoided	O
)	O
;	O
for	O
nested	O
names	O
(	O
including	O
both	O
namespaces	O
and	O
classes	B-Application
)	O
,	O
this	O
is	O
followed	O
by	O
,	O
then	O
a	O
series	O
of	O
length	O
,	O
id	O
pairs	O
(	O
the	O
length	O
being	O
the	O
length	O
of	O
the	O
next	O
identifier	O
)	O
,	O
and	O
finally	O
.	O
</s>
<s>
For	O
functions	O
,	O
this	O
is	O
then	O
followed	O
by	O
the	O
type	O
information	O
;	O
as	O
is	O
a	O
function	B-Language
,	O
this	O
is	O
simply	O
;	O
hence	O
:	O
</s>
<s>
For	O
,	O
the	O
standard	O
type	O
(	O
which	O
is	O
a	O
for	O
)	O
is	O
used	O
,	O
which	O
has	O
the	O
special	O
alias	O
;	O
a	O
reference	O
to	O
this	O
type	O
is	O
therefore	O
,	O
with	O
the	O
complete	O
name	O
for	O
the	O
function	B-Language
being	O
:	O
</s>
<s>
There	O
is	O
n't	O
a	O
standardized	O
scheme	O
by	O
which	O
even	O
trivial	O
C++	B-Language
identifiers	O
are	O
mangled	O
,	O
and	O
consequently	O
different	O
compilers	B-Language
(	O
or	O
even	O
different	O
versions	O
of	O
the	O
same	O
compiler	B-Language
,	O
or	O
the	O
same	O
compiler	B-Language
on	O
different	O
platforms	O
)	O
mangle	O
public	O
symbols	O
in	O
radically	O
different	O
(	O
and	O
thus	O
totally	O
incompatible	O
)	O
ways	O
.	O
</s>
<s>
Consider	O
how	O
different	O
C++	B-Language
compilers	B-Language
mangle	O
the	O
same	O
functions	O
:	O
</s>
<s>
The	O
Compaq	O
C++	B-Language
compiler	B-Language
on	O
OpenVMS	O
VAX	O
and	O
Alpha	O
(	O
but	O
not	O
IA-64	O
)	O
and	O
Tru64	O
has	O
two	O
name	B-Language
mangling	I-Language
schemes	O
.	O
</s>
<s>
The	O
original	O
,	O
pre-standard	O
scheme	O
is	O
known	O
as	O
the	O
ARM	O
model	O
,	O
and	O
is	O
based	O
on	O
the	O
name	B-Language
mangling	I-Language
described	O
in	O
the	O
C++	B-Language
Annotated	O
Reference	O
Manual	O
(	O
ARM	O
)	O
.	O
</s>
<s>
With	O
the	O
advent	O
of	O
new	O
features	O
in	O
standard	O
C++	B-Language
,	O
particularly	O
templates	B-Application
,	O
the	O
ARM	O
scheme	O
became	O
more	O
and	O
more	O
unsuitable	O
—	O
it	O
could	O
not	O
encode	O
certain	O
function	B-Language
types	O
,	O
or	O
produced	O
identically	O
mangled	B-Language
names	I-Language
for	O
different	O
functions	O
.	O
</s>
<s>
It	O
was	O
therefore	O
replaced	O
by	O
the	O
newer	O
"	O
ANSI	O
"	O
model	O
,	O
which	O
supported	O
all	O
ANSI	O
template	B-Application
features	O
,	O
but	O
was	O
not	O
backward	O
compatible	O
.	O
</s>
<s>
On	O
IA-64	O
,	O
a	O
standard	O
Application	B-Operating_System
Binary	I-Operating_System
Interface	I-Operating_System
(	O
ABI	B-Operating_System
)	O
exists	O
(	O
see	O
external	O
links	O
)	O
,	O
which	O
defines	O
(	O
among	O
other	O
things	O
)	O
a	O
standard	O
name-mangling	O
scheme	O
,	O
and	O
which	O
is	O
used	O
by	O
all	O
the	O
IA-64	O
compilers	B-Language
.	O
</s>
<s>
GNU	B-Application
GCC	I-Application
3.x	O
,	O
in	O
addition	O
,	O
has	O
adopted	O
the	O
name	B-Language
mangling	I-Language
scheme	O
defined	O
in	O
this	O
standard	O
for	O
use	O
on	O
other	O
,	O
non-Intel	O
platforms	O
.	O
</s>
<s>
The	O
Visual	O
Studio	O
and	O
Windows	O
SDK	O
include	O
the	O
program	O
which	O
prints	O
the	O
C-style	O
function	B-Language
prototype	O
for	O
a	O
given	O
mangled	B-Language
name	I-Language
.	O
</s>
<s>
On	O
Microsoft	O
Windows	O
,	O
the	O
Intel	O
compiler	B-Language
and	O
Clang	B-Application
uses	O
the	O
Visual	B-Application
C++	I-Application
name	B-Language
mangling	I-Language
for	O
compatibility	O
.	O
</s>
<s>
The	O
job	O
of	O
the	O
common	O
C++	B-Language
idiom	O
:	O
</s>
<s>
is	O
to	O
ensure	O
that	O
the	O
symbols	O
within	O
are	O
"	O
unmangled	O
"	O
–	O
that	O
the	O
compiler	B-Language
emits	O
a	O
binary	O
file	O
with	O
their	O
names	O
undecorated	O
,	O
as	O
a	O
C	B-Language
compiler	B-Language
would	O
do	O
.	O
</s>
<s>
As	O
C	B-Language
language	I-Language
definitions	O
are	O
unmangled	O
,	O
the	O
C++	B-Language
compiler	B-Language
needs	O
to	O
avoid	O
mangling	O
references	O
to	O
these	O
identifiers	O
.	O
</s>
<s>
If	O
the	O
had	O
not	O
been	O
used	O
,	O
the	O
(	O
SunPro	O
)	O
C++	B-Language
compiler	B-Language
would	O
produce	O
code	O
equivalent	O
to	O
:	O
</s>
<s>
Since	O
those	O
symbols	O
do	O
not	O
exist	O
in	O
the	O
C	B-Language
runtime	O
library	O
(	O
e.g.	O
</s>
<s>
It	O
would	O
seem	O
that	O
standardized	O
name	B-Language
mangling	I-Language
in	O
the	O
C++	B-Language
language	I-Language
would	O
lead	O
to	O
greater	O
interoperability	O
between	O
compiler	B-Language
implementations	O
.	O
</s>
<s>
However	O
,	O
such	O
a	O
standardization	O
by	O
itself	O
would	O
not	O
suffice	O
to	O
guarantee	O
C++	B-Language
compiler	B-Language
interoperability	O
and	O
it	O
might	O
even	O
create	O
a	O
false	O
impression	O
that	O
interoperability	O
is	O
possible	O
and	O
safe	O
when	O
it	O
is	O
n't	O
.	O
</s>
<s>
Name	B-Language
mangling	I-Language
is	O
only	O
one	O
of	O
several	O
application	B-Operating_System
binary	I-Operating_System
interface	I-Operating_System
(	O
ABI	B-Operating_System
)	O
details	O
that	O
need	O
to	O
be	O
decided	O
and	O
observed	O
by	O
a	O
C++	B-Language
implementation	O
.	O
</s>
<s>
Other	O
ABI	B-Operating_System
aspects	O
like	O
exception	B-General_Concept
handling	I-General_Concept
,	O
virtual	B-Language
table	I-Language
layout	O
,	O
structure	O
,	O
and	O
stack	O
frame	O
padding	B-Application
also	O
cause	O
differing	O
C++	B-Language
implementations	O
to	O
be	O
incompatible	O
.	O
</s>
<s>
A	O
standardized	O
requirement	O
for	O
name	B-Language
mangling	I-Language
would	O
also	O
prevent	O
an	O
implementation	O
where	O
mangling	O
was	O
not	O
required	O
at	O
all	O
—	O
for	O
example	O
,	O
a	O
linker	B-Application
that	O
understood	O
the	O
C++	B-Language
language	I-Language
.	O
</s>
<s>
The	O
C++	B-Language
standard	O
therefore	O
does	O
not	O
attempt	O
to	O
standardize	O
name	B-Language
mangling	I-Language
.	O
</s>
<s>
On	O
the	O
contrary	O
,	O
the	O
Annotated	O
C++	B-Language
Reference	O
Manual	O
(	O
also	O
known	O
as	O
ARM	O
,	O
,	O
section	O
7.2.1c	O
)	O
actively	O
encourages	O
the	O
use	O
of	O
different	O
mangling	O
schemes	O
to	O
prevent	O
linking	B-Application
when	O
other	O
aspects	O
of	O
the	O
ABI	B-Operating_System
are	O
incompatible	O
.	O
</s>
<s>
Nevertheless	O
,	O
as	O
detailed	O
in	O
the	O
section	O
above	O
,	O
on	O
some	O
platforms	O
the	O
full	O
C++	B-Language
ABI	B-Operating_System
has	O
been	O
standardized	O
,	O
including	O
name	B-Language
mangling	I-Language
.	O
</s>
<s>
Because	O
C++	B-Language
symbols	O
are	O
routinely	O
exported	O
from	O
DLL	O
and	O
shared	O
object	O
files	O
,	O
the	O
name	B-Language
mangling	I-Language
scheme	O
is	O
not	O
merely	O
a	O
compiler-internal	O
matter	O
.	O
</s>
<s>
Different	O
compilers	B-Language
(	O
or	O
different	O
versions	O
of	O
the	O
same	O
compiler	B-Language
,	O
in	O
many	O
cases	O
)	O
produce	O
such	O
binaries	O
under	O
different	O
name	B-Language
decoration	I-Language
schemes	O
,	O
meaning	O
that	O
symbols	O
are	O
frequently	O
unresolved	O
if	O
the	O
compilers	B-Language
used	O
to	O
create	O
the	O
library	O
and	O
the	O
program	O
using	O
it	O
employed	O
different	O
schemes	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
a	O
system	O
with	O
multiple	O
C++	B-Language
compilers	B-Language
installed	O
(	O
e.g.	O
,	O
GNU	B-Application
GCC	I-Application
and	O
the	O
OS	O
vendor	O
's	O
compiler	B-Language
)	O
wished	O
to	O
install	O
the	O
Boost	B-Language
C++	I-Language
Libraries	I-Language
,	O
it	O
would	O
have	O
to	O
be	O
compiled	B-Language
multiple	O
times	O
(	O
once	O
for	O
GCC	B-Application
and	O
once	O
for	O
the	O
vendor	O
compiler	B-Language
)	O
.	O
</s>
<s>
It	O
is	O
good	O
for	O
safety	O
purposes	O
that	O
compilers	B-Language
producing	O
incompatible	O
object	B-Language
codes	I-Language
(	O
codes	O
based	O
on	O
different	O
ABIs	O
,	O
regarding	O
e.g.	O
,	O
classes	B-Application
and	O
exceptions	O
)	O
use	O
different	O
name	B-Language
mangling	I-Language
schemes	O
.	O
</s>
<s>
This	O
guarantees	O
that	O
these	O
incompatibilities	O
are	O
detected	O
at	O
the	O
linking	B-Application
phase	O
,	O
not	O
when	O
executing	O
the	O
software	O
(	O
which	O
could	O
lead	O
to	O
obscure	O
bugs	O
and	O
serious	O
stability	O
issues	O
)	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
name	B-Language
decoration	I-Language
is	O
an	O
important	O
aspect	O
of	O
any	O
C++	B-Language
-related	O
ABI	B-Operating_System
.	O
</s>
<s>
There	O
are	O
instances	O
,	O
particularly	O
in	O
large	O
,	O
complex	O
code	O
bases	O
,	O
where	O
it	O
can	O
be	O
difficult	O
or	O
impractical	O
to	O
map	O
the	O
mangled	B-Language
name	I-Language
emitted	O
within	O
a	O
linker	B-Application
error	O
message	O
back	O
to	O
the	O
particular	O
corresponding	O
token/variable	O
-name	O
in	O
the	O
source	O
.	O
</s>
<s>
This	O
problem	O
can	O
make	O
identifying	O
the	O
relevant	O
source	O
file(s )	O
very	O
difficult	O
for	O
build	O
or	O
test	O
engineers	O
even	O
if	O
only	O
one	O
compiler	B-Language
and	O
linker	B-Application
are	O
in	O
use	O
.	O
</s>
<s>
Demanglers	B-Language
(	O
including	O
those	O
within	O
the	O
linker	B-Application
error	B-General_Concept
reporting	I-General_Concept
mechanisms	O
)	O
sometimes	O
help	O
but	O
the	O
mangling	O
mechanism	O
itself	O
may	O
discard	O
critical	O
disambiguating	O
information	O
.	O
</s>
<s>
The	O
format	O
of	O
signatures	O
is	O
documented	O
,	O
as	O
the	O
language	O
,	O
compiler	B-Language
,	O
and	O
.class	O
file	O
format	O
were	O
all	O
designed	O
together	O
(	O
and	O
had	O
object-orientation	O
and	O
universal	O
interoperability	O
in	O
mind	O
from	O
the	O
start	O
)	O
.	O
</s>
<s>
The	O
scope	O
of	O
anonymous	O
classes	B-Application
is	O
confined	O
to	O
their	O
parent	O
class	O
,	O
so	O
the	O
compiler	B-Language
must	O
produce	O
a	O
"	O
qualified	O
"	O
public	O
name	O
for	O
the	O
inner	B-Language
class	I-Language
,	O
to	O
avoid	O
conflict	O
where	O
other	O
classes	B-Application
with	O
the	O
same	O
name	O
(	O
inner	O
or	O
not	O
)	O
exist	O
in	O
the	O
same	O
namespace	O
.	O
</s>
<s>
Similarly	O
,	O
anonymous	O
classes	B-Application
must	O
have	O
"	O
fake	O
"	O
public	O
names	O
generated	O
for	O
them	O
(	O
as	O
the	O
concept	O
of	O
anonymous	O
classes	B-Application
only	O
exists	O
in	O
the	O
compiler	B-Language
,	O
not	O
the	O
runtime	O
)	O
.	O
</s>
<s>
All	O
of	O
these	O
class	O
names	O
are	O
valid	O
(	O
as	O
$	O
symbols	O
are	O
permitted	O
in	O
the	O
JVM	O
specification	O
)	O
and	O
these	O
names	O
are	O
"	O
safe	O
"	O
for	O
the	O
compiler	B-Language
to	O
generate	O
,	O
as	O
the	O
Java	O
language	O
definition	O
advises	O
not	O
to	O
use	O
$	O
symbols	O
in	O
normal	O
java	O
class	O
definitions	O
.	O
</s>
<s>
Name	O
resolution	O
in	O
Java	O
is	O
further	O
complicated	O
at	O
runtime	O
,	O
as	O
fully	B-Protocol
qualified	I-Protocol
class	I-Protocol
names	I-Protocol
are	O
unique	O
only	O
inside	O
a	O
specific	O
classloader	B-Language
instance	O
.	O
</s>
<s>
Classloaders	B-Language
are	O
ordered	O
hierarchically	O
and	O
each	O
Thread	O
in	O
the	O
JVM	O
has	O
a	O
so-called	O
context	O
class	B-Language
loader	I-Language
,	O
so	O
in	O
cases	O
where	O
two	O
different	O
classloader	B-Language
instances	O
contain	O
classes	B-Application
with	O
the	O
same	O
name	O
,	O
the	O
system	O
first	O
tries	O
to	O
load	O
the	O
class	O
using	O
the	O
root	O
(	O
or	O
system	O
)	O
classloader	B-Language
and	O
then	O
goes	O
down	O
the	O
hierarchy	O
to	O
the	O
context	O
class	B-Language
loader	I-Language
.	O
</s>
<s>
Java	O
's	O
native	B-Language
method	I-Language
support	O
allows	O
Java	O
language	O
programs	O
to	O
call	O
out	O
to	O
programs	O
written	O
in	O
another	O
language	O
(	O
generally	O
either	O
C	B-Language
or	O
C++	B-Language
)	O
.	O
</s>
<s>
Normal	O
C++	B-Language
name	B-Language
mangling	I-Language
-	O
see	O
above	O
.	O
</s>
<s>
In	O
Python	B-Language
,	O
mangling	O
is	O
used	O
for	O
class	O
attributes	O
that	O
one	O
does	O
not	O
want	O
subclasses	O
to	O
use	O
which	O
are	O
designated	O
as	O
such	O
by	O
giving	O
them	O
a	O
name	O
with	O
two	O
or	O
more	O
leading	O
underscores	O
and	O
no	O
more	O
than	O
one	O
trailing	O
underscore	O
.	O
</s>
<s>
Python	B-Language
's	O
runtime	O
does	O
not	O
restrict	O
access	O
to	O
such	O
attributes	O
,	O
the	O
mangling	O
only	O
prevents	O
name	O
collisions	O
if	O
a	O
derived	O
class	O
defines	O
an	O
attribute	O
with	O
the	O
same	O
name	O
.	O
</s>
<s>
On	O
encountering	O
name	O
mangled	O
attributes	O
,	O
Python	B-Language
transforms	O
these	O
names	O
by	O
prepending	O
a	O
single	O
underscore	O
and	O
the	O
name	O
of	O
the	O
enclosing	O
class	O
,	O
for	O
example	O
:	O
</s>
<s>
To	O
avoid	O
name	B-Language
mangling	I-Language
in	O
Pascal	B-Application
,	O
use	O
:	O
</s>
<s>
Free	B-Operating_System
Pascal	I-Operating_System
supports	O
function	B-Language
and	O
operator	O
overloading	B-Application
,	O
thus	O
it	O
also	O
uses	O
name	B-Language
mangling	I-Language
to	O
support	O
these	O
features	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
Free	B-Operating_System
Pascal	I-Operating_System
is	O
capable	O
of	O
calling	O
symbols	O
defined	O
in	O
external	O
modules	B-Architecture
created	O
with	O
another	O
language	O
and	O
exporting	O
its	O
own	O
symbols	O
to	O
be	O
called	O
by	O
another	O
language	O
.	O
</s>
<s>
Name	B-Language
mangling	I-Language
is	O
also	O
necessary	O
in	O
Fortran	B-Application
compilers	B-Language
,	O
originally	O
because	O
the	O
language	O
is	O
case	O
insensitive	O
.	O
</s>
<s>
Further	O
mangling	O
requirements	O
were	O
imposed	O
later	O
in	O
the	O
evolution	O
of	O
the	O
language	O
because	O
of	O
the	O
addition	O
of	O
modules	B-Architecture
and	O
other	O
features	O
in	O
the	O
Fortran	B-Application
90	O
standard	O
.	O
</s>
<s>
The	O
case	O
mangling	O
,	O
especially	O
,	O
is	O
a	O
common	O
issue	O
that	O
must	O
be	O
dealt	O
with	O
in	O
order	O
to	O
call	O
Fortran	B-Application
libraries	O
,	O
such	O
as	O
LAPACK	B-Application
,	O
from	O
other	O
languages	O
,	O
such	O
as	O
C	B-Language
.	O
</s>
<s>
Because	O
of	O
the	O
case	O
insensitivity	O
,	O
the	O
name	O
of	O
a	O
subroutine	O
or	O
function	B-Language
must	O
be	O
converted	O
to	O
a	O
standardized	O
case	O
and	O
format	O
by	O
the	O
compiler	B-Language
so	O
that	O
it	O
will	O
be	O
linked	O
in	O
the	O
same	O
way	O
regardless	O
of	O
case	O
.	O
</s>
<s>
Different	O
compilers	B-Language
have	O
implemented	O
this	O
in	O
various	O
ways	O
,	O
and	O
no	O
standardization	O
has	O
occurred	O
.	O
</s>
<s>
The	O
AIX	B-Application
and	O
HP-UX	B-Application
Fortran	B-Application
compilers	B-Language
convert	O
all	O
identifiers	O
to	O
lower	O
case	O
,	O
while	O
the	O
Cray	O
and	O
Unicos	B-Operating_System
Fortran	B-Application
compilers	B-Language
converted	O
identifiers	O
to	O
all	O
upper	O
case	O
.	O
</s>
<s>
The	O
GNU	B-Operating_System
g77	B-Application
compiler	B-Language
converts	O
identifiers	O
to	O
lower	O
case	O
plus	O
an	O
underscore	O
,	O
except	O
that	O
identifiers	O
already	O
containing	O
an	O
underscore	O
have	O
two	O
underscores	O
appended	O
,	O
following	O
a	O
convention	O
established	O
by	O
f2c	B-Language
.	O
</s>
<s>
Many	O
other	O
compilers	B-Language
,	O
including	O
SGI	O
's	O
IRIX	B-Operating_System
compilers	B-Language
,	O
GNU	B-Application
Fortran	I-Application
,	O
and	O
Intel	O
's	O
Fortran	B-Application
compiler	B-Language
(	O
except	O
on	O
Microsoft	O
Windows	O
)	O
,	O
convert	O
all	O
identifiers	O
to	O
lower	O
case	O
plus	O
an	O
underscore	O
(	O
and	O
,	O
respectively	O
)	O
.	O
</s>
<s>
On	O
Microsoft	O
Windows	O
,	O
the	O
Intel	O
Fortran	B-Application
compiler	B-Language
defaults	O
to	O
uppercase	O
without	O
an	O
underscore	O
.	O
</s>
<s>
Identifiers	O
in	O
Fortran	B-Application
90	O
modules	B-Architecture
must	O
be	O
further	O
mangled	O
,	O
because	O
the	O
same	O
procedure	O
name	O
may	O
occur	O
in	O
different	O
modules	B-Architecture
.	O
</s>
<s>
Since	O
the	O
Fortran	B-Application
2003	O
Standard	O
requires	O
that	O
module	B-Architecture
procedure	O
names	O
not	O
conflict	O
with	O
other	O
external	O
symbols	O
,	O
compilers	B-Language
tend	O
to	O
use	O
the	O
module	B-Architecture
name	O
and	O
the	O
procedure	O
name	O
,	O
with	O
a	O
distinct	O
marker	O
in	O
between	O
.	O
</s>
<s>
In	O
this	O
module	B-Architecture
,	O
the	O
name	O
of	O
the	O
function	B-Language
will	O
be	O
mangled	O
as	O
(	O
e.g.	O
,	O
GNU	B-Application
Fortran	I-Application
)	O
,	O
(	O
e.g.	O
,	O
Intel	O
's	O
ifort	O
)	O
,	O
(	O
e.g.	O
,	O
Oracle	O
's	O
sun95	O
)	O
,	O
etc	O
.	O
</s>
<s>
Since	O
Fortran	B-Application
does	O
not	O
allow	O
overloading	B-Application
the	O
name	O
of	O
a	O
procedure	O
,	O
but	O
uses	O
generic	O
interface	O
blocks	O
and	O
generic	O
type-bound	O
procedures	O
instead	O
,	O
the	O
mangled	B-Language
names	I-Language
do	O
not	O
need	O
to	O
incorporate	O
clues	O
about	O
the	O
arguments	O
.	O
</s>
<s>
The	O
Fortran	B-Application
2003	O
BIND	O
option	O
overrides	O
any	O
name	B-Language
mangling	I-Language
done	O
by	O
the	O
compiler	B-Language
,	O
as	O
shown	O
above	O
.	O
</s>
<s>
Function	B-Language
names	O
are	O
mangled	O
by	O
default	O
in	O
Rust	B-Application
.	O
</s>
<s>
However	O
,	O
this	O
can	O
be	O
disabled	O
by	O
the	O
function	B-Language
attribute	O
.	O
</s>
<s>
This	O
attribute	O
can	O
be	O
used	O
to	O
export	O
functions	O
to	O
C	B-Language
,	O
C++	B-Language
,	O
or	O
Objective-C	B-Language
.	O
Additionally	O
,	O
along	O
with	O
the	O
function	B-Language
attribute	O
or	O
the	O
crate	O
attribute	O
,	O
it	O
allows	O
the	O
user	O
to	O
define	O
a	O
C-style	O
entry	O
point	O
for	O
the	O
program	O
.	O
</s>
<s>
Rust	B-Application
has	O
used	O
many	O
versions	O
of	O
symbol	O
mangling	O
schemes	O
that	O
can	O
be	O
selected	O
at	O
compile	B-Language
time	O
with	O
an	O
option	O
.	O
</s>
<s>
A	O
C++	B-Language
style	O
mangling	O
based	O
on	O
the	O
Itanium	O
IA-64	O
C++	B-Language
ABI	B-Operating_System
.	O
</s>
<s>
Used	O
since	O
Rust	B-Application
1.9	O
.	O
</s>
<s>
An	O
improved	O
version	O
of	O
the	O
legacy	O
scheme	O
,	O
with	O
changes	O
for	O
Rust	B-Application
.	O
</s>
<s>
Polymorphism	B-Application
can	O
be	O
encoded	O
.	O
</s>
<s>
Functions	O
do	O
n't	O
have	O
return	O
types	O
encoded	O
(	O
Rust	B-Application
does	O
not	O
have	O
overloading	B-Application
)	O
.	O
</s>
<s>
Unicode	O
names	O
use	O
modified	O
punycode	B-General_Concept
.	O
</s>
<s>
Used	O
since	O
Rust	B-Application
1.37	O
.	O
</s>
<s>
Examples	O
are	O
provided	O
in	O
the	O
Rust	B-Application
tests	O
.	O
</s>
<s>
Essentially	O
two	O
forms	O
of	O
method	O
exist	O
in	O
Objective-C	B-Language
,	O
the	O
class	O
(	O
"	O
static	O
"	O
)	O
method	O
,	O
and	O
the	O
instance	B-Language
method	I-Language
.	O
</s>
<s>
A	O
method	O
declaration	O
in	O
Objective-C	B-Language
is	O
of	O
the	O
following	O
form	O
:	O
</s>
<s>
Class	O
methods	O
are	O
signified	O
by	O
+	O
,	O
instance	B-Language
methods	I-Language
use	O
-	O
.	O
</s>
<s>
With	O
instance	B-Language
methods	I-Language
looking	O
like	O
this	O
:	O
</s>
<s>
When	O
compiled	B-Language
,	O
each	O
method	O
is	O
named	O
according	O
to	O
the	O
following	O
scheme	O
for	O
class	O
methods	O
:	O
</s>
<s>
and	O
this	O
for	O
instance	B-Language
methods	I-Language
:	O
</s>
<s>
The	O
colons	O
in	O
the	O
Objective-C	B-Language
syntax	O
are	O
translated	O
to	O
underscores	O
.	O
</s>
<s>
So	O
,	O
the	O
Objective-C	B-Language
class	O
method	O
,	O
if	O
belonging	O
to	O
the	O
class	O
would	O
translate	O
as	O
,	O
and	O
the	O
instance	B-Language
method	I-Language
(	O
belonging	O
to	O
the	O
same	O
class	O
)	O
would	O
translate	O
to	O
.	O
</s>
<s>
In	O
Objective-C	B-Language
,	O
one	O
can	O
manage	O
selectors	O
directly	O
—	O
they	O
have	O
a	O
specific	O
type	O
in	O
Objective-C	B-Language
—	O
.	O
</s>
<s>
During	O
compilation	B-Language
,	O
a	O
table	O
is	O
built	O
that	O
maps	O
the	O
textual	O
representation	O
,	O
such	O
as	O
,	O
to	O
selectors	O
(	O
which	O
are	O
given	O
a	O
type	O
)	O
.	O
</s>
<s>
Note	O
that	O
a	O
selector	O
only	O
matches	O
a	O
method	O
's	O
name	O
,	O
not	O
the	O
class	O
it	O
belongs	O
to	O
—	O
different	O
classes	B-Application
can	O
have	O
different	O
implementations	O
of	O
a	O
method	O
with	O
the	O
same	O
name	O
.	O
</s>
<s>
Message	O
sends	O
are	O
encoded	O
by	O
the	O
compiler	B-Language
as	O
calls	O
to	O
the	O
function	B-Language
,	O
or	O
one	O
of	O
its	O
cousins	O
,	O
where	O
is	O
the	O
receiver	O
of	O
the	O
message	O
,	O
and	O
determines	O
the	O
method	O
to	O
call	O
.	O
</s>
<s>
There	O
are	O
separate	O
tables	O
for	O
class	O
and	O
instance	B-Language
methods	I-Language
.	O
</s>
<s>
The	O
value	O
for	O
a	O
selector	O
does	O
not	O
vary	O
between	O
classes	B-Application
.	O
</s>
<s>
This	O
enables	O
polymorphism	B-Application
.	O
</s>
<s>
The	O
Objective-C	B-Language
runtime	O
maintains	O
information	O
about	O
the	O
argument	O
and	O
return	O
types	O
of	O
methods	O
.	O
</s>
<s>
Since	O
Objective-C	B-Language
does	O
not	O
support	O
namespaces	O
,	O
there	O
is	O
no	O
need	O
for	O
the	O
mangling	O
of	O
class	O
names	O
(	O
that	O
do	O
appear	O
as	O
symbols	O
in	O
generated	O
binaries	O
)	O
.	O
</s>
<s>
This	O
metadata	O
includes	O
the	O
function	B-Language
's	O
name	O
,	O
attributes	O
,	O
module	B-Architecture
name	O
,	O
parameter	O
types	O
,	O
return	O
type	O
,	O
and	O
more	O
.	O
</s>
<s>
The	O
mangled	B-Language
name	I-Language
for	O
a	O
method	O
of	O
a	O
class	O
in	O
module	B-Architecture
is	O
,	O
for	O
2014	O
Swift	O
.	O
</s>
<s>
:	O
Non-curried	O
function	B-Language
.	O
</s>
<s>
:	O
Function	B-Language
of	O
a	O
class	O
,	O
i.e.	O
</s>
<s>
:	O
Module	B-Architecture
name	O
,	O
prefixed	O
with	O
its	O
length	O
.	O
</s>
<s>
:	O
Name	O
of	O
class	O
the	O
function	B-Language
belongs	O
to	O
,	O
prefixed	O
with	O
its	O
length	O
.	O
</s>
<s>
:	O
Function	B-Language
name	O
,	O
prefixed	O
with	O
its	O
length	O
.	O
</s>
<s>
:	O
The	O
function	B-Language
attribute	O
.	O
</s>
<s>
In	O
this	O
case	O
‘	O
f’	O
,	O
which	O
means	O
a	O
normal	O
function	B-Language
.	O
</s>
<s>
:	O
This	O
begins	O
the	O
type	O
list	O
for	O
the	O
parameter	O
tuple	O
of	O
the	O
function	B-Language
.	O
</s>
<s>
:	O
External	O
name	O
of	O
first	O
parameter	O
of	O
the	O
function	B-Language
.	O
</s>
