Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

__declspec VERSUS _stdcall

Status
Not open for further replies.

nhungr

Programmer
Joined
Jan 31, 2005
Messages
26
Location
CA
I'm calling a C++ DLL from another application written in Visual Basic. When declaring a function in the DLL, what's the difference between using __declspec as opposed to _stdcall? For example:
Code:
void __declspec(dllexport) CALLBACK MyFunction()

   [COLOR=green]//or:[/color]

void _stdcall MyFunction()
Is one better than the other?
 
Using of __declspec and __stdcall are ortogonal. Use __declspec(dllexport) to export a (function or variable) name from a dll (w/o another specs in .DEF file).
__stdcall defines calling conventions for its function (only) name (specifies so called Fortran convention).
As far as I know, CALLBACK implies __stdcall.

So __declspec(dllexport) is not better than __stdcall (and vice versa)...
 
__declspec(dllexport) is not a calling convention. It just exports the function so executables can use them. It is mainly used in dlls.

__stdcall is a calling convention. See this for related information on Microsoft calling conventions.
 
for all exported functions from a DLL, that you will use in Visual Basic you HAVE TO put the __stdcall calling convention (the OS code works under this convention, too)

so. you should have BOTH options of them like that:

__declspec(dllexport) void __stdcall foo(int, int, char*);

s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Similar threads

  • Locked
  • Question Question
Replies
11
Views
532

Part and Inventory Search

Sponsor

Back
Top