Why are there so many macros in WINAPI that are essentially the same?
For example, WINAPI and CALLBACK are essentially the same, but with different names.
What was invented this type riot?
For the same reasons why we invent different names for variables, rather than using i1, i2, i3 ... for integers and b1, b2, b3 ... for boolean ones. Name of type, variable, class, etc. should reflect its purpose and give maximum information about its use. The prefix WINAPI indicates that the function is part of the Windows API, and is subject to its calling convention. CALLBACK says that this is a user-defined function called by some WinAPI function. The fact that somewhere in the wilds of windef.h both of them are defined as __stdcall is nothing more than a coincidence that the programmer should not be interested in. And by the way, as for these definitions, they do not coincide for all platforms.
Another goal of WinAPI definitions is platform independence. If I declare a variable as a DWORD , it does not matter to me that it is on my system that it will be declared as unsigned long . It is enough to know that it will be four-byte on any platform, even where long is 64 bits long.
Source: https://ru.stackoverflow.com/questions/888837/
All Articles