Hi My VC2008 project uses the stdcall calling conventions. I have an external library that I am using which has been built with cdecl naming convention, however they didn't mention the calling convention in the function declaration of the functions.
I would like to know if VC has some kind of #pragma or other keyword that would force specific calling convention for the entire header file
kinda like the extern "C" trick but for calling conventions:
extern "C"
{
#include <file1.h>
#include <file2.h>
}
Anyone knows of such?
__cdecl is the default calling convention for C and C++ programs. Because the stack is cleaned up by the caller, it can do vararg functions.
In CDECL arguments are pushed onto the stack in revers order, the caller clears the stack and result is returned via processor registry (later I will call it "register A"). In STDCALL there is one difference, the caller doeasn't clear the stack, the calle do.
The __stdcall calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes vararg functions __cdecl . Functions that use this calling convention require a function prototype. The __stdcall modifier is Microsoft-specific.
The __fastcall calling convention specifies that arguments to functions are to be passed in registers, when possible. This calling convention only applies to the x86 architecture.
You can specify calling convention by:
__cdecl
explicitly (or perhaps through a macro).There's no pragma or anything similiar to control calling convention.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With