What is the point of defining a calling convention?

后端 未结 5 1496
醉话见心
醉话见心 2021-01-24 06:20

For example:

int WINAPI WinMain ( HINSTANCE instance, HINSTANCE prev_instance, PSTR cmd_line, int cmd_show )

WINAPI is a a define that looks li

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-24 07:02

    Because the WINAPI calling convention is not guaranteed to be __stdcall. Code that uses WINAPI will still be correct even when it isn't.

    You can write the function as in your latter example, and it'd work fine - it's just not good practice and would not be portable to a platform where the calling convention is something else.

提交回复
热议问题