This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Variadic macros and commas
- From: ext at sidvind dot com
- To: "Ian Lance Taylor" <iant at google dot com>
- Cc: "David Sveningsson" <ext at sidvind dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 1 Mar 2007 20:36:39 +0100 (CET)
- Subject: Re: Variadic macros and commas
- References: <45E69A48.3070903@sidvind.com> <m3irdk25tn.fsf@localhost.localdomain>
> David Sveningsson <ext@sidvind.com> writes:
>
>> It keeps adding pointers until NULL is reached, thus the argument list
>> must be ended with NULL. If 'first' is NULL an empty array is returned.
>> However too often NULL is forgotten causing nasty bugs.
>
> You may find the sentinel function attribute to be useful here. It is
> a gcc extension which adds a warnings if the function is called
> without a trailing NULL.
>
> Ian
>
Yes, I tried the sentinel attribute but since it's valid to call the
function without any arguments at all (the first argument default to NULL)
the sentinel warns that not enough arguments has been passed.