On Wed, Jul 18, 2001 at 08:47:15PM +0300, Peter Pentchev wrote:
> On Wed, Jul 18, 2001 at 07:34:08PM +0200, Sheldon Hearn wrote:
> > 
> > Hi folks,
> > 
> > I'm busy developing a libdaemon implementation and have come unstuck on
> > a weird problem with functions using variable argument lists in FreeBSD
> > 4.3-STABLE.
> > 
> > What I really want is a static inline void function declared in a header
> > file and included in various source files, looking something like this:
> > 
> > static inline void
> > xdaemonwarn(char *fmt, ...)
> > {
> >     va_list ap;
> > 
> >     va_start(ap, fmt);
> >     if (!daemon_quiet)
> >             warn(fmt, ap);
> >     va_end(ap);
> > 
> >     return;
> > }
> 
> Errrrrr.  Snipped the rest, since this code snippet contains
> an important mistake.
> 
> warn() does not take a va_list as an argument.
> Try using vwarn(fmt, ap) instead, and your function looks fine.

To elaborate a bit: a va_list is a pointer to a memory area where
the arguments are stored; a '...' means that this actual memory
area lies on the stack.  Thus, a va_list is a *pointer* to what
warn() expects, and it is exactly this pointer that vwarn() needs.

G'luck,
Peter

-- 
I am jealous of the first word in this sentence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to