Solved

STDCALL or PASCAL??

Posted on 1997-04-18
1
1,011 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
1 Comment
 
LVL 3

Accepted Solution

by:
sperling earned 25 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now