Summary of C + + technical issues-what is the 13th calling convention and what is different

Source: Internet
Author: User

calling convention (calling convention), determines the following:

A. The stacking order of the function parameters.

B. The arguments are popped by the caller or by the caller.

C. And the method that produces the function decorated name.

Common calling conventions are __stdcall,__cdecl,__fastcall.

1) __stdcall.

Standardcall 's abbreviation, agreed content:

A. Parameters are pressed from right to left onto the stack.

B. The function is called by the caller to modify the stack.

C. The output function name is preceded by an underscore prefix, followed by an "@" symbol and the number of bytes of its parameters, in the format [email protected], For example: function (int a, int b)with the decorated name:[email protected]

Typically used in the Win32 Api , primarily in Microsoft Visual c,C + +.

Corresponding macro definition: #define WINAPI __stdcall

2) __cdecl.

C Declaration 's abbreviation, agreed content:

A. Parameters are stacked from right to left.

B. Caller cleanup stack, commonly known as manual clearing stack.

C. The output function name is preceded by an underscore prefix, formatted as _functionname.

The __cdecl is the default function call method for C + + languages.

3) __fastcall.

To increase the call speed, the first two (or several) parameters are passed by the register, and the remaining parameters are passed through the stack.

Quick call, contract content:

A. Parameters are pressed from right to left onto the stack.

B. The function is called by the caller to modify the stack.

C. The output function name is preceded by an "@" symbol, followed by an "@" symbol and the number of bytes of its parameter, in the format @[email protected] .

Different compiler-compiled programs stipulate different registers. On the Intel x86 platform, use the ECX and EDX registers. You cannot use the __fastcall method as a cross-compiler interface.

Summary of C + + technical issues-what is the 13th calling convention and what is different

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.