Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

STDCALL or PASCAL??

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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