cdecl keyword

Guy Harris guy at gorodish.Sun.COM
Tue Apr 5 10:19:27 AEST 1988


> There is a hidden gem in the ANSI C spec. That is, all functions are
> presumed to have a fixed number of parameters unless they are specifically
> prototyped as having variable args, and that prototype must appear before
> any use of the function. The big advantage here is that now the compiler
> can select the most efficient function call sequence on a case-by-case
> basis. This can be a big win, and would eliminate a major reason for
> coding in assembly (arguments could be passed in registers!).

Umm, the lack of function prototyping certainly didn't stop *us* from passing
arguments in registers; I don't know if MIPS's or Pyramid's compilers have it,
but if they don't it didn't stop them either.  If the compiler can somehow
detect, when compiling a function, that the function is intended to be called
in "varargs" form, it can have it dump the requisite arguments onto the stack.
In our compiler, it detects this by having "va_alist" be a #define for
"__builtin_va_alist", and have the compiler recognize that magic name; I think
MIPS detects attempts to take the address of an argument.  I don't know how
Pyramid handles varargs.

Our scheme only requires functions that "cheat" to stop doing so and use
"varargs"; MIPS's may not even require that.



More information about the Comp.lang.c mailing list