varargs
George Robbins
grr at cbmvax.cbm.UUCP
Sun Apr 13 05:05:20 AEST 1986
In article <272 at vecpyr.UUCP> greg at vecpyr.UUCP (Greg Millar) writes:
>I have always heard that varargs is not very portable. Is this really
>true? If you know of any machine that is running 4.X BSD, System III/V,
>Xenix or any other real unix that doesn't support varargs, please let
>me know.
>
>Under AIX there are 3 functions associated with varargs called:
>vsprintf, vprintf, vfprintf. Are these only available on the IBM RT PC?
>
> Greg Millar {ucbvax,decwrl}!dual!vecpyr!greg
> Visual Engineering, Inc. 2680 N. First San Jose, CA 95134
You have to define precisly what you mean by varargs...
The strict/slimey definition that works on many/most unix systems is that a
*C* function can index through its argument list in a linear fashion by taking
the address of the first argument and incrementing by the length of each
argument (which you must know or be told). This assumes that the arguments
are all stored in some contiguous, rational order on the stack or in some
parameter block. It is also generally assumed that a function can pass its
arguments to a function it calls, without knowing anything about them.
(frequent example: debug functions whose arguments are passed to printf)
Since these conventions are known not to work on all machines, it was decided
to create a set of 'magical' varargs routines that would allow a C program
to access it's arguments in a machine independent way. Supposedly the
vprintf, etc. routines are reimplementations of printf, etc. that make use
of the these machine independent varargs conventions.
As you might expect, implementations where strict/slimey varargs works on the
hardware people tend to be careless about implementing/using the machine
independent form, and people who are stuck with implementations that require
the machine independent form tend to be kind of bitter about 'portable' code
created using the strict/slimey conventions.
--
George Robbins - now working with, uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing arpa: cbmvax!grr at seismo.css.GOV
Commodore, Engineering Department fone: 215-431-9255 (only by moonlite)
More information about the Comp.unix.wizards
mailing list