Windows dlls hell... indeed

Here are a few notes about the win32 programming hell...
To load a library in VC++ use LoadLibrary. For that purpose you need to
include <windows.h>
To export a function in a dll, create a def file or use the

_declspec (dllexport) funcName()

declaration. If you choose to use __stdcall then it specifies standard or PASCAL calling convention (don't ask me what is it... I guess it has something to do with the arguments). You can easily combine them in a declaration. There is also some other convention __cdecl but again google for it.
for more information read
here
By the way, don't use the precompiled header shit, you don't need it.

At last!!! here is some more about calling conventions. From CodeProject
I've also learned what is the meaning of the strange function names while debugging.. namely _funcname@24 thats a function docoration done by the calling function...
Here are the differences between the calling conventions in short:

  • __cdecl is the default calling convention for C and C++ programs. The advantage of this calling convetion is that it allows functions with a variable number of arguments to be used. The disadvantage is that it creates larger executables.
  • __stdcall is used to call Win32 API functions. It does not allow functions to have a variable number of arguments.
  • __fastcall attempts to put arguments in registers, rather than on the stack, thus making function calls faster.
  • Thiscall calling convention is the default calling convention used by C++ member functions that do not use variable arguments.

Post a Comment

Previous Post Next Post