stdcall and cdecl

后端 未结 9 862
旧时难觅i
旧时难觅i 2020-11-27 09:17

There are (among others) two types of calling conventions - stdcall and cdecl. I have few questions on them:

  1. When a cdecl fun
9条回答
  •  醉梦人生
    2020-11-27 10:08

    Calling conventions have nothing to do with the C/C++ programming languages and are rather specifics on how a compiler implements the given language. If you consistently use the same compiler, you never need to worry about calling conventions.

    However, sometimes we want binary code compiled by different compilers to inter-operate correctly. When we do so we need to define something called the Application Binary Interface (ABI). The ABI defines how the compiler converts the C/C++ source into machine-code. This will include calling conventions, name mangling, and v-table layout. cdelc and stdcall are two different calling conventions commonly used on x86 platforms.

    By placing the information on the calling convention into the source header, the compiler will know what code needs to be generated to inter-operate correctly with the given executable.

提交回复
热议问题