C99 variadic macros
John Baldwin
jhb at FreeBSD.org
Thu Feb 5 12:44:19 PST 2004
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 at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the freebsd-arch
mailing list