C and C + + name decoration rules

Source: Internet
Author: User

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

    1. Question mark Prefix
    2. 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.
    3. If it is not a special function name, add a delimiter @
    4. 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.
    5. 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.
    6. The return value is encoded. For example, the character H represents the return value of an integer type
    7. parameter list encoding, ending with the @ symbol.
    8. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.