Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!cbmvax!grr From: grr@cbmvax.cbm.UUCP (George Robbins) Newsgroups: net.lang.c,net.unix-wizards Subject: Re: varargs Message-ID: <77@cbmvax.cbmvax.cbm.UUCP> Date: Sat, 12-Apr-86 14:05:20 EST Article-I.D.: cbmvax.77 Posted: Sat Apr 12 14:05:20 1986 Date-Received: Wed, 16-Apr-86 03:23:24 EST References: <272@vecpyr.UUCP> Reply-To: grr@cbmvax.UUCP (George Robbins) Organization: Commodore Technology, West Chester, PA Lines: 39 Keywords: portability, varargs Xref: watmath net.lang.c:8559 net.unix-wizards:17587 In article <272@vecpyr.UUCP> greg@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@seismo.css.GOV Commodore, Engineering Department fone: 215-431-9255 (only by moonlite)