C Function Calling conventions

  1. __cdecl
  • Standard/default calling convention in Unix/Win32
  • Caller should push and pop the arguments (right to left)
  • Variable number of argument functions such as printf, scanf can be used with because the callee cannot know the number of parameters
  • Freeing stack Instructions are inserted after every call of the function, so it increases the code size if many calls are made
  1. __stdcall/PASCAL
  • Microsoft Win32 supported
  • Arguments are pushed (left to right) by the called and stack is cleaned up by the callee
  • No variable number of argument functions are allowed
  • Conserve some code space (one time cleanup by callee)
  1. __fastcall
  • Microsoft Win32 supported
  • Registers are used for passing arguments
  • The registers are pushed to and popped from the stack (first two arguments are copied into the registers, the rest should resort to the stack by_stdcall fashion)
  • Bit overhead
  • Used for local functions within the module

Check out more detailed explanation

No comments yet

Leave a reply

You must be logged in to post a comment.