[comp.lang.c] varargs in the world

garry@batcomputer.tn.cornell.edu (Garry Wiegand) (11/19/86)

Are there any compilers/RTL's out there which do *not* support "varargs"?

garry wiegand   (garry%cadif-oak@cu-arpa.cs.cornell.edu)

(((Questing for the holy portable code...)))

rbutterworth@watrose.UUCP (Ray Butterworth) (11/20/86)

> Are there any compilers/RTL's out there which do *not* support "varargs"?

There are a few.  In the future there will be many more.

The proposed ANSI X3J11 C standard has put <stdarg.h> into its library,
and added "extern int func(arg1,arg2,...);" to the C language.  (The
"..." in that example really is entered into the source as three dots.)
This is an improvement over the <varargs.h> approach, but it is not
compatible with it (in particular since there has to be at least one
parameter before the ",..." part).

On any machine and compiler a varargs.h could probably be implemented,
but it would have to be very machine specific (e.g. is it the caller
or the function that allocates stack space for the arguments?  or does
that type of function simply get passed a pointer to a variable length
list of arguments?).  It could not be done by using the <stdarg.h>
definitions.  It might need some assembly language functions for
accessing the arguments.

It is even possible that a strict X3J11 compiler would reject any
function call that contains a different number of arguments if
that function is not declared with the ",..." syntax.

The varargs and the stdarg macros are very similar, but they are
different.  Converting source code from one to the other is fairly
trivial, but it is still something that has to be done by hand.

henry@utzoo.UUCP (Henry Spencer) (11/25/86)

> Are there any compilers/RTL's out there which do *not* support "varargs"?

If you look long and hard, you can probably find a few.  I got an M.Sc.
thesis out of the problems involved in compiling C for a Pascal-oriented
machine whose architecture insisted on knowing the total size of the
parameters passed to each function.  Note, *the* total size -- it had to
be the same for all calls.  The architecture did not provide the primitives
necessary for building your own calling sequence, either.  Apart from some
really horrible trickery with compiler and loader cooperating, the only
fix was new microcode.  That's what was eventually done to make C viable
on that thing; varargs was only the beginning of its problems.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry