Thread: calling conventions

  1. #1
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715

    calling conventions

    Hello, I'm reading about C calling conventions.
    I found this explanation:
    "The pascal keyword is
    used in the prototype and definition of the function to tell the compiler to
    use this convention. In fact, MS Windows API C functions use the Pascal
    convention. Why? It is a little more efficient than the C convention."

    And this:

    "The difference in stdcall and cdecl is that stdcall requires the subroutine
    to remove the parameters from the stack (as the Pascal calling convention
    does). Thus, the stdcall convention can only be used with functions that
    take a fixed number of arguments (i.e. ones not like printf and scanf)."


    If someone can explain me what is difference between stdcall and pascal calling convection. In MSDN I found #define WINAPI __stdcall, so according to this API uses stdcall convention.
    I also found in MSD when learning win socket api this:
    "
    int PASCAL FAR bind ( SOCKET s, const struct sockaddr FAR * name, int namelen); "

    So it uses Pascal convention.

    Thanks very much for help!

  2. #2
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >If someone can explain me what is difference between stdcall and pascal calling convection.
    IIRC, the two refer to the same calling convention. PASCAL is defined with stdcall.

  3. #3
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    You're rghit, I found what you said in windef.h.
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack issues when calling a COM library
    By notnot in forum C Programming
    Replies: 3
    Last Post: 06-01-2009, 02:12 AM
  2. Forcing code conventions
    By audinue in forum Tech Board
    Replies: 28
    Last Post: 03-31-2009, 08:46 AM
  3. Calling conventions
    By Mario F. in forum Tech Board
    Replies: 16
    Last Post: 01-15-2009, 10:55 AM
  4. Replies: 2
    Last Post: 09-16-2005, 11:44 PM
  5. Question on function syntax and calling function
    By cbrman in forum C Programming
    Replies: 10
    Last Post: 10-05-2003, 05:32 PM