Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!uwvax!husc6!harvard!panda!genrad!decvax!mcnc!rti-sel!dg_rtp!meissner From: meissner@dg_rtp.UUCP (Michael Meissner) Newsgroups: net.lang.c Subject: Re: variable # of args portability? Message-ID: <434@dg_rtp.UUCP> Date: Wed, 9-Jul-86 09:46:55 EDT Article-I.D.: dg_rtp.434 Posted: Wed Jul 9 09:46:55 1986 Date-Received: Fri, 11-Jul-86 05:34:29 EDT References: <809@ucbcad.BERKELEY.EDU> Reply-To: meissner@dg_rtp.UUCP (Michael Meissner) Distribution: net Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 28 Keywords: vprintf, vfprintf, and vsprintf In article <809@ucbcad.BERKELEY.EDU> faustus@ucbcad.UUCP writes: > > 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 In the forthcoming ANSI X3J11 standard, as well as System V, are the functions vprintf, vfprintf, and vsprintf. Instead of taking the argument list directly, the take the varargs pointer. Thus the calling sequence looks like (in the ANSI declarative style): int vprintf( const char *fmt, va_list varargs_ptr ); int vfprintf( FILE *stream, const char *fmt, va_list varargs_ptr ); int vsprintf( char *buffer, const char *fmt, va_list varargs_ptr ); For systems that do not have vprintf and friends yet, you could write the vprintf, et. al, in a few lines of code calling _doprnt. This would have to be tailored for each system. Michael Meissner, Data General ...{ decvax, ucbvax, ihnp4 }!mcnc!rti-sel!dg_rtp!meissner