Path: utzoo!attcan!uunet!lll-winken!ames!haven!adm!cmcl2!phri!marob!samperi From: samperi@marob.MASA.COM (Dominick Samperi) Newsgroups: comp.lang.c Subject: Re: passing variable numbers of arguments Message-ID: <449@marob.MASA.COM> Date: 8 Jan 89 18:47:52 GMT References: <899@thor.stolaf.edu> <15341@mimsy.UUCP> Reply-To: samperi@marob.masa.com (Dominick Samperi) Distribution: na Organization: ESCC New York City Lines: 31 In article <15341@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >[comments about System V style varargs usage...] It seems that for the ANSI style varargs (that is, the one requiring stdarg.h), at least one explicitly named arg must be included in the function definition, so that there is a FIRST that can be supplied to va_start, as in: va_list ap ; va_start(sp, FIRST) ; ... x = va_arg(ap, TYPE) ; ... va_end(ap) ; Is this correct? If not, how does one define a function with a variable number of args, for which there are no explicitly named args? The standard documentation on this (K&R Second Edition, for example) does not make this clear. It also seems to be the case that it is not possible for a called function (with a variable number of args) to determine how many args were actually passed, or when the last arg has been fetched, unless this information is supplied in the first parameter, say. Wouldn't it have been reasonable for the standard to specify that the compiler should enable the called function to determine the number of parameters that were passed, by automatically passing this information as a first implicit parameter, for example? Dominick Samperi samperi@acf8.nyu.edu uunet!hombre!samperi