Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!ll-xn!husc6!necntc!ima!haddock!karl From: karl@haddock.UUCP (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: using varargs function to call another varargs function Message-ID: <675@haddock.UUCP> Date: Thu, 2-Jul-87 14:35:57 EDT Article-I.D.: haddock.675 Posted: Thu Jul 2 14:35:57 1987 Date-Received: Sat, 4-Jul-87 08:04:53 EDT References: <1332@rosevax.Rosemount.COM> <7268@mimsy.UUCP> Reply-To: karl@haddock.ISC.COM (Karl Heuer) Organization: Interactive Systems, Boston Lines: 28 In article <7268@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <1332@rosevax.Rosemount.COM> dave@rosesun.Rosemount.COM >(Dave Marquardt) [asks how to write a private variadic function which passes >its va_alist to some public variadic function such as curses' wprintw]. > >No [you can't do that]. [The more important problem] is that wprintw takes a >variable argument list, not a single argument of type `va_list'. > >System V has some of what you need in the form of `vprintf'. If >curses had a wvprintw, you could [pass the va_alist to it]. Curses *should* have a wvprintw, or vwprintw as it would probably be called. (It has neither, at least not in the version I have here.) More generally, each truly variadic function% should have a corresponding v-function. I've never needed a vscanf, but that should exist too, just for completeness. >This is clearly the Right Way to allow this sort of thing; indeed, it >suggests that printf, fprintf, and sprintf themselves be implemented using > (or ), and hence portable. Some implementations do exactly that, so that vfprintf is called by each of the other 5 functions, which are written in C and (except for vsprintf using undocumented properties of FILE) are portable. The lowest-level routine, vfprintf, could be written in C but is often written in assembly for speed. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint %"truly variadic function" is intended to exclude functions with a bounded number of optional arguments, of which "open" may or may not be an example.