C/C ++ function call Specification

Source: Internet
Author: User

In the future, technical notes will be recorded on this blog.
When I encountered this problem during compilation principles today, I sorted it out.

The parameter pressure stack and rollback methods are determined by the function call specification.
Most function call parameters are pushed from right to left to stack, because we read the parameters from left to right.
Common call specifications for Windows:
Call Specification
Description
_ Cdecl
The default call specification for C/C ++ programs. Parameters are transferred from right to left, and the call function is responsible for moving the parameters from the stack. This facilitates passing a variable number of parameters.
_ Stdcall
The call specification used by this WindowAPI function. The parameter is transferred from right to left, and the called function is responsible for removing the parameter from the stack. The code generated by this specification is smaller than _ cdecl, but the _ cdecl specification will still be used when the function has variable parameters. WINAPI, CALLBACK, and APIENTRY macros are defined as _ stdcall specifications.
Thiscall
(Non-Keyword)
The default call specification for C ++ member functions. variable parameters are not used. Except that the this pointer is saved in the ECX register rather than in the stack, the others are the same as _ stdcall. Note: Use the _ stdcall specification for COM member functions

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.