_stdcall and __cdecl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pugal

    #1

    _stdcall and __cdecl

    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
  • Bruno van Dooren

    #2
    Re: _stdcall and __cdecl

    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/de...onventions.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
    bruno_nos_pam_v an_dooren@hotma il.com
    Remove only "_nos_pam"


    Comment

    • Pugal

      #3
      Re: _stdcall and __cdecl

      Hi Bruno

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

      -Pugal

      "Bruno van Dooren" wrote:
      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/de...onventions.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
      bruno_nos_pam_v an_dooren@hotma il.com
      Remove only "_nos_pam"
      >
      >
      >

      Comment

      Working...