Date: Thu, 5 Feb 2004 15:44:48 -0500 From: John Baldwin <jhb@FreeBSD.org> To: Stefan Farfeleder <stefan@fafoe.narf.at> Cc: arch@freebsd.org Subject: Re: C99 variadic macros Message-ID: <200402051544.48349.jhb@FreeBSD.org> In-Reply-To: <20040205200454.GD602@wombat.fafoe.narf.at> References: <20040205164639.GC602@wombat.fafoe.narf.at> <200402051405.59533.john@baldwin.cx> <20040205200454.GD602@wombat.fafoe.narf.at>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 05 February 2004 03:04 pm, Stefan Farfeleder wrote: > On Thu, Feb 05, 2004 at 02:05:59PM -0500, John Baldwin wrote: > > On Thursday 05 February 2004 11:46 am, Stefan Farfeleder wrote: > > > #define foo(fmt, args...) printf("%s: " fmt "\n", __func__, ##args) > > > > C99 macros don't work when args is 0. I.e., if I did: > > > > foo("test"); > > > > The C99 _VA_ARGS_ think doesn't delete the , whereas the GCC way does. > > While it's true that the ellipsis must match a positive number of > arguments, this isn't necessarily a problem. You just use "..." for > both the format string and its arguments. Not always easily done in my experience, though the 3 printf thing (ugh) might serve as a workaround as I didn't try that before when I've tried to use the C99 way. -- John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200402051544.48349.jhb>