Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!nike!ucbcad!ucbvax!decvax!decwrl!glacier!mips!hansen From: hansen@mips.UUCP Newsgroups: net.lang.c Subject: Re: variable # of args portability? Message-ID: <551@mips.UUCP> Date: Tue, 8-Jul-86 23:15:57 EDT Article-I.D.: mips.551 Posted: Tue Jul 8 23:15:57 1986 Date-Received: Thu, 10-Jul-86 01:21:47 EDT References: <809@ucbcad.BERKELEY.EDU> Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 27 > I want to be able to write a function that will take an unknown number > of arguments and then call another such function with these arguments, > namely something like printf() that calls _doprnt() without processing > its arguments at all. I know there is no way to write this code portably, > but is it reasonable to assume that I will be able to do it at all in > most common implementations of C? Also, how safe is it to assume that there > will be something like _doprnt() available? I know it's not good to depend on > things like this, but I don't want to have to write my own printf()... > > Wayne System V defines functions named vprintf, vfprintf, and vsprintf, that combined with the macros defined in varargs.h, provide a reasonably portable interface to _doprnt. The first two functions are trivial to implement on a machine that has _doprnt, the third is a little tricker, since you must trick the stdio package into outputting into a string, and the necessary flag setting is rather unportable (which is why the v...printf functions should be defined in the system-provided library). Using varargs.h goes a long way toward making such functions portable. -- Craig Hansen | "Evahthun' tastes MIPS Computer Systems | bettah when it ...decwrl!mips!hansen | sits on a RISC"