How to force cdecl to call convention for functions declared in a specific header file

Hi My VC2008 project uses stdcall calling conventions. I have an external library that I use that was built using the cdecl naming convention, however they did not mention the calling convention in the function function declaration.

I would like to know if VC has some kind of #pragma or some other keyword that would force a specific calling convention for the whole header file

sort of like an extern "C" trick, but for calling conventions:

extern "C" { #include <file1.h> #include <file2.h> } 

Does anyone know about these?

+7
source share
1 answer

You can specify a calling convention:

  • Do nothing, and you get the default value for cdecl.
  • Specify __cdecl explicitly (or perhaps through a macro).
  • We choose to use cdecl in the entire translation unit by compiling with / Gd.

There is no pragma or anything like that to govern the convention.

+4
source

All Articles