sjsam
sjsam

Reputation: 21965

Conventions for name mangling

For a function say :

long myfunction(int,float)

the compiler may document this interface as, say :

?MyFunctionFoo@@YAXH

If I understand correctly, the additional characters decorating the original name encodes the number and types of parameters.

All that the standard says(1.3.17) about mangling is :

Signatures are used as a basis for name mangling and linking.

Do compilers follow a standard convention for the encoding scheme mentioned above?

Alternatively, are two compilers required to give identical decorated name for the same function?

Upvotes: 3

Views: 553

Answers (2)

cpp_enthusiast
cpp_enthusiast

Reputation: 1299

Do compilers follow a standard convention for the encoding scheme mentioned above?

No, there is no standard convention for the name mangling encoding scheme. Each compiler has its own name mangling scheme.

Some of them are described here name mangling scheme. Please go to the name mangling section in the document.

Upvotes: 0

Nicol Bolas
Nicol Bolas

Reputation: 473322

Do all compilers follow a single standard scheme?

No. Which answers your second question too.

Name mangling is a function of an ABI. And there are standard ABIs, which multiple compilers generate code for. The Itanium ABI, for example, has its own name mangling scheme that several compilers implement.

But the C++ standard gives no requirements for name mangling. Indeed, it doesn't even say that such name mangling is required.

Upvotes: 5

Related Questions