Reputation: 858
I have made a dll and exported the functions inside it using
_declspec(dllexport)
at the extreme left of the function definition.
like :
_declspec(dllexport) void func1(char*p);
Is this correct method to export functions as somewhere?
I have read about _stdcall
like:
_declspec(dllexport) void _stdcall func1(char*p);
or
_declspec(dllexport) void _cdecl func1(char*p);
Please explain the difference between these three as I am confused .
Upvotes: 1
Views: 109
Reputation: 13690
All of your declaration are correct. The important thing is that you provide a appropriate header file for the calling module that uses your DLL. e.g. one of
_declspec(dllimport) void func1(char*p);
_declspec(dllimport) void _stdcall func1(char*p);
or
_declspec(dllimport) void _cdecl func1(char*p);
Upvotes: 0
Reputation: 15546
Your first signature is correct. So are the second and third. However, _stdcall
and _cdecl
are calling conventions which specify the ordering of parameters in callstack and some other things while the call is made. For example, '_thiscall' is another calling convention which means that the this
pointer will be passed via a register(ECX) during function calling.
So, in short all three will work but all three specify some internal details of how call would be made.
You might need to read this article to know more about Calling Conventions:
Upvotes: 1