Date: Wed, 18 Jul 2001 20:51:34 +0300 From: Peter Pentchev <roam@orbitel.bg> To: Sheldon Hearn <sheldonh@starjuice.net> Cc: freebsd-hackers@FreeBSD.org Subject: Re: Weird <stdarg.h> problem in 4.3-STABLE Message-ID: <20010718205134.D635@ringworld.oblivion.bg> In-Reply-To: <20010718204715.C635@ringworld.oblivion.bg>; from roam@orbitel.bg on Wed, Jul 18, 2001 at 08:47:15PM %2B0300 References: <11254.995477648@axl.seasidesoftware.co.za> <20010718204715.C635@ringworld.oblivion.bg>
next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010718205134.D635>