cdecl keyword ( re: C Decl ... )

Rahul Dhesi dhesi at bsu-cs.UUCP
Fri Apr 1 02:19:44 AEST 1988


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.

Now if you compile a routine that needs to be linked with a Pascal
program, you may compile it thus:

     cc -pascal mystuff.c

If mystuff.c uses any C library function, you still want that library
function to be called using the C calling convention, even though you
asked the compiler to generate code for the Pascal calling convention.
If mystuff.c includes a header file declaring library functions, and
the header file uses the cdecl keyword for these, then the compiler
will correctly use the Pascal or C calling convention, whichever is
needed by the called routine.

With a little foresight Microsoft could have just used the same calling
convention in all its language translators.  The "cdecl" keyword is a
belated fix for a problem that need not have existed.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi



More information about the Comp.lang.c mailing list