Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

STDCALL or PASCAL??

Posted on 1997-04-18
1
Medium Priority
?
1,078 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 50 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

916 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