cdecl and pascal keywords
Pete Kvitek
kvitekp at jvd.msk.su
Thu Dec 27 15:24:34 AEST 1990
In article <26075 at uflorida.cis.ufl.EDU> jdb at reef.cis.ufl.edu (Brian K. W. Hook) writes:
>I know that C and Pascal pass parameters differently and clean up the calling
>stack differently, but I was wondering whether there is a NOTICEABLE difference
>in speed and size of program that uses PASCAL declarations for fixed argument
>functios and the cdecl declaration for variable...e.g.
>
[ stuff deleted ]
>
>Assume that parameters can be passed, also, just a fixed amount....I know
>main() has to be declared as cdecl, but otherwise, is it possible for me
>to change all of my other functions to pascal declarations without any
>side effects?
>
>And will I actually gain anything? I know a lot fo Windows prototypes are
>prototype with the PASCAL keyword.
>
>Brian
The order in which parameters are pushed on the stack
does not seem to make any speed or size difference.
However, if procedure uses C calling conventions, then
calling procedure is responsible for cleaning up stack
after _every_ call, thus consuming some extra memory in
code segment. Pascal procedure cleans up stack _before_
returning to the caller.
This probably explains why Windows designers choose
pascal calling conventions since Windows code usually
contains huge amount of references to the Windows
libraries.
Another reason to use pascal calling convections is to
conserve stack space with heavily nested procedures
(for example recourcive ones).
> Pete
--
--
Pete I. Kvitek <kvitekp at jvd.msk.su> | Phone: (095) 328-1327
Speaking from but not for JV Dialogue, Moscow, USSR | Fax: (095) 329-4711
More information about the Comp.lang.c
mailing list