Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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)

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:

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 Delphi, 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
517 views
Welcome To Ask or Share your Answers For Others

1 Answer

The "CALLBACK" is a calling convention. There are other kinds of calling conventions. CALLBACK is the same as __stdcall.

http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557

Some more information at Raymond Chen's blog:

http://blogs.msdn.com/oldnewthing/archive/2004/01/08/48616.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...