C Name Decoration rules
1. For functions that use the __cdecl calling convention, add a dash before the function name, regardless of the parameter and return value.
2. For functions that use the __fastcall calling convention, add an @ sign before and after the function name, followed by the length of the parameter, regardless of the return value.
For example, the decorated name of extern "C" int __fastcall Test (int n) is @[email protected]
3. For functions that use the __stdcall standard calling convention, add an underscore to the function name, followed by an @ sign after the name and the length of the parameter, regardless of the return value.
For example, the decorated name of extern "C" int __stdcall Test (int n,int m) is [email protected]
C + + Name decoration components
- Question mark Prefix
- The function name or method name that does not include the class name. Constructors and destructors have special civil claims, which are 0 and 1 respectively. Operator overloading also has special names, such as new, delete, =, +, and + +, with the names of 2,? 3,? 4,? H and? E, we simply call these special function names as special function names.
- If it is not a special function name, add a delimiter @
- In the case of a method of a class, the owning class starts with the class name and the parent class name, followed by an @ symbol after each class name, with all the class names added, plus an @ symbol and a character Q or S (static method). If it is not a method of the class, add the @ symbol and the character y directly.
- calling convention code. For a function that does not belong to any class, the C calling convention (__cdecl) code for the A,__fastcall Convention is I,__stdcall Code is G, and for a class method, the calling convention adds a character a,this the code for the call to E.
- The return value is encoded. For example, the character H represents the return value of an integer type
- parameter list encoding, ending with the @ symbol.
- Suffix Z.
C + + Name decoration composition Rule
A: All start with, end with the character Z, the middle is divided into multiple parts by the @ symbol. The length of the entire name is 2048 bytes maximum.
Second: For the function of the class, its basic structure is:? method name @ Class name @@ 调用 convention return type parameter list Z.
Three: For functions that do not belong to any class, its basic structure: the function name @@y the calling convention returns the type parameter list Z.
For example:
int __cdecl TestFunc (int, int) decorated with the name [email protected]@[email protected]
@y indicates a method that is not a class
A represents the calling convention __cdecl
An h represents the return value as an integer type, and the last two H represents two integer parameters
The public int ctest::setname (char*,...) decorated name is [email protected]@ @QAAHPADZZ
? is the prefix
Setsetname is the method name
CTest is the class name
@q indicates end of class name
The first A is the calling convention prefix for the C + + method, followed by a for the C calling convention (because the declaration contains a variable number of parameters, the compiler automatically uses _cdecl).
H = return value type (integer)
Pad is the parameter code, z is the suffix
Again for example the constructor
Public:ctest::ctest (void), decorated with a name of [email Protected]@[email protected]
? 0 represents a constructor
CTest represents the class name
@q indicates end of class name
AE represents the this calling convention
For example, operator overloading:
Public:void ctest::operator Delete (void*) modifier name is [email protected]@[email protected]
@s means that the overloaded delete operator is automatically compiled into a static method, as is the case with overloading new.
C and C + + name decoration rules