什么是一个"回拨"声明用C呢? [英] What does a "CALLBACK" declaration in C do?
问题描述
我一直在寻找通过从 SDL 库约code和跨功能传来:
I was looking through some code from the SDL library and came across a function declared like this:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
现在,我是一个Delphi $ C $铬。没有habloÇMUY边,感光芯片。不过,我记得从我的大学课程足够的语法像这样来阅读:
Now, I'm a Delphi coder. No hablo C muy bien, senor. But I remember enough syntax from my college courses to read it like this:
函数名称的WndProc。参数列表是pretty言自明。函数返回类型是LRESULT。但在世界什么是回调在那里做什么?在Delphi中,任何功能可以用作一个回调;你只需要传递正确类型的函数指针。有什么特别的原因C不工作方式?还是意味着不同的东西?
Function name is WndProc. Argument list is pretty self-explanatory. Function return type is LRESULT. But what in the world is that "CALLBACK" doing there? In Delp any function can be used as a callback; you just need to pass the right type of function pointer. Is there any particular reason why C doesn't work that way? Or does it mean something different?
推荐答案
回调是一个调用约定。还有其他类型的调用约定的。回调一样__stdcall。
The "CALLBACK" is a calling convention. There are other kinds of calling conventions. CALLBACK is the same as __stdcall.
<一个href=\"http://www.$c$cguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557\">http://www.$c$cguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557
在Raymond Chen的博客的一些详细信息:
Some more information at Raymond Chen's blog:
<一个href=\"http://blogs.msdn.com/oldnewthing/archive/2004/01/08/48616.aspx\">http://blogs.msdn.com/oldnewthing/archive/2004/01/08/48616.aspx
这篇关于什么是一个&QUOT;回拨&QUOT;声明用C呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!