Solved

STDCALL or PASCAL??

Posted on 1997-04-18
1
1,018 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 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

10 Experts available now in Live!

Get 1:1 Help Now