gpt4 book ai didi

c++ - "LRESULT CALLBACK WinProc"和 "LRESULT WINAPI WinProc"之间的区别

转载 作者:行者123 更新时间:2023-11-28 04:13:12 25 4
gpt4 key购买 nike

我正在学习使用 DirectX9 创建游戏,我发现了 define WinProc 的不同版本:

LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)

我不知道它们之间有什么不同,我应该使用哪个版本?谢谢兄弟。

最佳答案

 #define CALLBACK   __stdcall

#define WINAPI __stdcall

从两者的宏观定义来看,它们是一样的。

MSDN :

CALLBACK, WINAPI, and APIENTRY are all used to define functionswith the __stdcall calling convention. Most functions in the WindowsAPI are declared using WINAPI. You may wish to use CALLBACK forthe callback functions that you implement to help identify thefunction as a callback function.

什么是 Windows 调用约定?

来自 MSDN :

The way the name is decorated depends on the language and how thecompiler is instructed to make the function available, that is, thecalling convention. The standard inter-process calling convention forWindows used by DLLs is known as the WinAPI convention. It is definedin Windows header files as WINAPI, which is in turn defined using theWin32 declarator __stdcall.

也就是说WINAPI、CALLBACK和_stdcall在Windows平台上是一样的。

您可以使用 CALLBACK 或 WINAPI。

关于c++ - "LRESULT CALLBACK WinProc"和 "LRESULT WINAPI WinProc"之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57231201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com