_stdcall and __cdecl

G

Guest

hi
what is the difference between _stdcall and __cdecl, is the stack
release issue much important.. and why other languages like java are not
worrying about these things.. any idea..

-Pugal
 
B

Bruno van Dooren

what is the difference between _stdcall and __cdecl, is the stack
release issue much important.. and why other languages like java are not
worrying about these things.. any idea..

one issue is that __cdecl supports functions with a variable number of
arguments, while _stdcall does not.
the reason is that with Stdcall, the callee has to pop arguments from the
stack. with varargs this cannot work since the callee cannot know what was
put on the stack in the first place.

another issue is that naming convention is different.

This page has a nice summary of the different calling conventions and their
differences:
http://msdn.microsoft.com/library/d...e_argument_passing_and_naming_conventions.asp

calling conventions are usually important if you are working with external
code,
because the other party needs to know how to call your functions.

for example, if you create a thread with _beginthreadex, the thread function
has to follow stdcall, while thread functions strated with _beginthread have
to follow __cdecl.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
G

Guest

Hi Bruno

I'm quite clear right now about _stdcall and __cdecl, thank you for your
answer.

-Pugal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top