Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 May 2008 08:58:29 -0700 (PDT)
From:      Unga <unga888@yahoo.com>
To:        Roland Smith <rsmith@xs4all.nl>
Cc:        Patrick Clochesy <pcloches@gmail.com>, freebsd-questions@freebsd.org
Subject:   Re: Variable arg function question [SOLVED]
Message-ID:  <861035.74979.qm@web57007.mail.re3.yahoo.com>
In-Reply-To: <20080504154734.GA98310@slackbox.xs4all.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--- Roland Smith <rsmith@xs4all.nl> wrote:

> On Sun, May 04, 2008 at 08:34:30AM -0700, Unga
> wrote:
> > 
> > --- Roland Smith <rsmith@xs4all.nl> wrote:
> > 
> > > On Sun, May 04, 2008 at 07:02:36AM -0700,
> Patrick
> > > Clochesy wrote:
> > > > What about using a macro (...) in front of the
> > > function to csll it which 
> > > > passes __VARARGS__, NULL to ensure there is
> always
> > > a trailing NULL? I think 
> > > > this would at least work in GCC... Can' test
> on my
> > > phone though.
> > > 
> > > That's a good idea. If one uses __VA_ARGS__
> instead
> > > of __VARARGS__, it
> > > should work with any C99 compliant compiler,
> > > including gcc.
> 
> > I gave it a try, but I cannot get it to work:
> > (As per above wikipedia example)
> > 
> > void realdprintf (char const *file, int line, char
> > const *fmt, ...); 
> > #define dprintf(...) realdprintf(__FILE__,
> __LINE__,
> > __VA_ARGS__)
> > 
> > To solve my problem, I must be able to indicate
> the
> > end of the arg list, may be by a empty string
> (""),
> > but GNU C compiler does not allow to specify
> anything
> > after the ... .
> 
> Try something like what Patrick suggested:
> 
> #define f(...) _f(__VA_ARGS__,NULL)
> 

Hey, it worked :) Thanks guys for the help. Appreciate
it very much.

Unga


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?861035.74979.qm>