Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Calling conventions

Calling conventions

Scheduled Pinned Locked Moved C / C++ / MFC
questiondelphi
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ravish
    wrote on last edited by
    #1

    What is the difference between C and Pascal calling convention ? I have heard that pascal calling convention saves bytes - Is it true ? IF true how ?

    P N 2 Replies Last reply
    0
    • R Ravish

      What is the difference between C and Pascal calling convention ? I have heard that pascal calling convention saves bytes - Is it true ? IF true how ?

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      The C calling convention puts the parameters on the stack from right to left, this allows the C calling convention to have an limitless parameter list like in the printf function. The caller pops parameters from the stack. The pascal calling convention is obsolete in WIN32, but it passes its parameters from left to right. I am not sure, but I believe that the callee pops parameters from the stack frame.

      R 1 Reply Last reply
      0
      • R Ravish

        What is the difference between C and Pascal calling convention ? I have heard that pascal calling convention saves bytes - Is it true ? IF true how ?

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #3

        I wrote a little article on calling conventions. However, you won't find anything about Pascal calling convention. It was replaced by stdcall in Win32 I vote pro drink :beer:

        1 Reply Last reply
        0
        • P Paul M Watt

          The C calling convention puts the parameters on the stack from right to left, this allows the C calling convention to have an limitless parameter list like in the printf function. The caller pops parameters from the stack. The pascal calling convention is obsolete in WIN32, but it passes its parameters from left to right. I am not sure, but I believe that the callee pops parameters from the stack frame.

          R Offline
          R Offline
          Rick York
          wrote on last edited by
          #4

          The pascal (stdcall) calling convention is not obsolete in Win32. Most of the Win32 API uses it. Is has various macros to describe it such as WINAPI, CALLBACK, APIPRIVATE, PASCAL, and IMAGEAPI. It is used for two reasons : first so that multiple programming languages can be supported and second because M$ claims that it is slightly more efficient. :rolleyes: Whatever. You are right that the callee fixes the stack. This is done by adding the number of bytes that were pushed back to ESP. BTW: I actually do have something that resembles a life but I have spent lots of time reading .cod listings. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups