cdecl keyword ( re: C Decl ... )

Greg Comeau greg at csanta.UUCP
Tue Apr 5 22:58:55 AEST 1988


In article <2521 at bsu-cs.UUCP> dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
>In article <7595 at brl-smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
>writes (about the "cdecl" keyword):
>>Of all the useless additions to C, this one has to take the cake!
>>#define cdecl /*nothing*/
>
>The real usefulness of cdecl comes when one is doing mixed language
>programming.
>

Right.  Another equally valid reason for having cdecl and pascal is
that you may choose to use the pascal modifier on your C routine even
though you do not have any mixed model code.

Why would you want to do this?  Because C builds the stack with the
current arguments every time it goes to do a subsroutine call and it
does not know or care how may arguments there actually is.  Pascal does.
So?  Well this means that the overhead for pascal function calls during
execution is faster because pascal type functions can clean up the
stack when they are finished with a 'ret #bytes' instruction.  With the
"standard" C calling concentions, the caller usually does the cleaning
up with an increment (decrement?) of the sp *after* the call to the function.

Result is: faster & smaller code.  Not too often that you can kill them two
birds with the same stone.



More information about the Comp.lang.c mailing list