Solved

STDCALL or PASCAL??

Posted on 1997-04-18
1
1,026 Views
Last Modified: 2006-11-17
I have a bunch of Delphi DLLs that I will want to use from C++ Builder (I just got it so haven't done any testing yet).  They all use the PASCAL calling convention.  I know that the Win32 standard is STDCALL.

I read, a few years ago, that for Intel processors, the PASCAL calling convention is more efficient that the C (CDECL) calling convention (though I can't remember why)...I do know that STDCALL is just a variant of CDECL.

So...first question...will C++ Builder support the PASCAL calling convention?  Or should I change the DLLs to support the STDCALL convention?  And, was there any truth to what I'd read about the PASCAL and CDECL conventions??
0
Comment
Question by:mheacock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
sperling earned 25 total points
ID: 1335457
C++Builder supports pascal calling convention.

When you create a 'pascal' or 'stdcall' function, the generated code for returning to the caller looks something like

RET 0008

This instruction both removes 8 bytes from stack, and returns to caller.

Using 'cdecl', the return instruction would simply be

RET

and then the caller would have to fix up the stack using another instruction. Therefore, 'pascal' and 'stdcall' are more efficient than 'cdecl'.

You won't notice this unless your function is called *very* frequently though.

Anyway, a good rule of thumb is to stick to 'stdcall' for your DLLs... This'll make life easier if/when someone other than yourself should need to use the DLL.

Regards,

Erik.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question