Archived

This topic is now archived and is closed to further replies.

superpeter

what is WINAPI, CALLBACK, LRESULT?

Recommended Posts

invective    118
Microsoft defines many of its own types such as INT instead of the default C/C++ int. This is mainly due to the fact that windows can span multiple architectures and can change in the future, as it did when windows moved from 16bit to 32bit, causing all c++ int to go from 16 to 32 bits. Thus if you use INT, the idea is you can just change the header defining INT and recompile your code for the new architecture with minimal changes. You can see that WINAPI is defined as __stdcall (for win32) or far pascal (win16) in windef.h depending on the target platform. This mainly has to do with the way arguments to the function are pushed on the stack (i.e. the backwards pascal order). CALLBACK is the same thing. LRESULT is just a LONG, or a long. You should just use the windows defined types wherever they are appropriate (like declaring WinMain) so that when and if the platform changes you do not have any problems recompiling code:

INT WINAPI WinMain

You could put

int __stdcall WinMain

but its less portable and considered bad style.

Share this post


Link to post
Share on other sites