Xref: utzoo comp.lang.c:8790 comp.sys.ibm.pc:13988 Path: utzoo!utgpu!water!watmath!clyde!att-cb!att-ih!pacbell!ames!ncar!gatech!mcnc!decvax!decwrl!pyramid!prls!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: C declaration styles Message-ID: <2801@mmintl.UUCP> Date: 1 Apr 88 15:19:40 GMT References: <1238@wjvax.UUCP> <297@ho7cad.ATT.COM> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Ashton-Tate Corporation, East Hartford Development Center Lines: 31 In article <297@ho7cad.ATT.COM> ekb@ho7cad.ATT.COM (Eric K. Bustad) writes: >No one else has asked, so I guess that I must reveal my ignorance. >Can someone explain the meaning of Microsoft's "cdecl" keyword? Microsoft (and a number of other PC C vendors) supports two subroutine calling conventions: "C" style and "Pascal" style. The Pascal style supports interface to Pascal, Fortran, and compiled Basic programs, as well as OS/2 system functions. The C style supports functions with a variable number of arguments. One can use the "pascal" keyword on a function declaration to specify that it is to be called with the pascal convention. Alternatively, one can use a compile switch to default all functions to pascal. In this case, it is necessary to have a keyword to specify that a function is to use the C convention. "cdecl" is it. (Some compilers support "fortran" as a synonym for "pascal".) (For those who care: there are two major differences between the two conventions. In C style, the calling function removes the arguments from the stack after the call; in Pascal style, the called function does so before returning. For C style, the arguments are pushed right to left; Pascal style is left to right. A minor difference is the way that struct values longer than 4 bytes are returned: C style is for the called function to put the result in static storage, and return a pointer to it; Pascal style is for the calling function to pass an additional argument, the address where the result is to be put.) -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108