我正在查看SDL库中的一些代码,并遇到了一个声明如下的函数:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Run Code Online (Sandbox Code Playgroud)
现在,我是德尔福编码器.没有hablo C muy bien,先生.但是我记得我的大学课程中有足够的语法来读它:
函数名称是WndProc.参数列表非常明显.函数返回类型是LRESULT.但是世界上那个"CALLBACK"在那里做什么呢?在Delphi中,任何函数都可以用作回调函数; 你只需要传递正确类型的函数指针.有什么特别的原因导致C不能这样工作吗?或者它意味着什么不同?
我知道__cdecl和之间的区别__stdcall是什么,但我不太确定为什么__stdcall在 x64 构建中被编译器忽略。
以下代码中的函数
int __stdcall stdcallFunc(int a, int b, int c, int d, int e, int f, int g)
{
return a + b + c + d + e + f + g;
}
int __cdecl cdeclFunc(int a, int b, int c, int d, int e, int f, int g)
{
return a + b + c + d + e + f + g;
}
int main()
{
stdcallFunc(1, 2, 3, …Run Code Online (Sandbox Code Playgroud)