Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.lang.c Subject: Re: stdarg Message-ID: <132@tdatirv.UUCP> Date: 7 Feb 91 18:31:45 GMT References: <588@taumet.com> <1991Feb6.171144.7182@Neon.Stanford.EDU> <1991Feb7.043715.1224@Think.COM> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 24 In article <1991Feb7.043715.1224@Think.COM> barmar@think.com (Barry Margolin) writes: >Well, consider a function taking a variable number of strings, followed by >a null pointer. The type is known by definition, and the number of >arguments can be determined by looking at them. > > While this style could >easily be replaced with one where there is an initial fixed argument >containing the count of variable arguments, that's more prone to error: Ah, but the style you specified above *does* have one 'fixed' argument, since all valid calls must pass *at* *least* one argument, a null pointer. (That is an attempt to call it with *no* arguments is a serious error). Furthermore this single required argument is of type (char *), even if it is the null pointer. Thus the specification: void sfunc(char *, ...); is a perfectly valid way of prototyping it. Thus the style you mentioned is in fact compatible with stdarg.h, and is best treated as requiring one character pointer argument. A varargs.h approach which pretends that there are no required arguments is actually misleading. -- --------------- uunet!tdatirv!sarima (Stanley Friesen)