Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

can I mix __stdcall export calls with __cdecl import calls in a DLL?

I am writing the windows application. using Windows WIN32.
I want to use the third party DLL it build using __stdcall.
but I am using __cdecl for my build. so it is not compliable to use both in same program.
is there any method to do that?

in library .h file defined the call faction like this.

#define CALLING_DECLARE extern "C" HRESULT WINAPI

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

While you can instruct the compiler to use a default calling convention (see /Gd, /Gr, /Gv, /Gz (Calling Convention)) you can still override that default by explicitly declaring the calling convention on each function declaration.

If you have set your project to use __cdecl by default you will have to mark imports from a DLL compiled using __stdcall as such, so as to not inherit the project defaults.

You can mix any number of calling conventions in a project without any issues, so long as the calling convention set at the function declaration (either explicitly or by using the default) matches the calling convention used by the implementation.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading