Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Feb 2004 14:05:59 -0500
From:      John Baldwin <john@baldwin.cx>
To:        Stefan Farfeleder <stefan@fafoe.narf.at>, arch@freebsd.org
Subject:   Re: C99 variadic macros
Message-ID:  <200402051405.59533.john@baldwin.cx>
In-Reply-To: <20040205164639.GC602@wombat.fafoe.narf.at>
References:  <20040205164639.GC602@wombat.fafoe.narf.at>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 05 February 2004 11:46 am, Stefan Farfeleder wrote:
> Hi,
>
> I went through the source tree and converted all occurrences of
> GNU-style variadic macros to C99 compliant ones in !contrib code.
> For macros that (ab)use string concatenation like
>
> #define foo(fmt, args...)	printf("%s: " fmt "\n", __func__, ##args)
>
> three printf's must be used.  As almost all variadic macros are used for
> debugging, this shouldn't matter much.  Two occurrences
> (src/lib/libypclnt/ypclnt.h and src/sys/dev/ichsmb/ichsmb.c) remain
> since they can't be converted easily and are already protected by
> defined(__GNUC__).
>
> 	http://www.ten15.org/~stefanf/FreeBSD/vamacro.diff

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.

-- 
John Baldwin <john@baldwin.cx>  <><  http://www.baldwin.cx/~john/
"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?200402051405.59533.john>