This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: macro __VAR_ARGS_ bug??
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Reza Roboubi <reza at linisoft dot com>
- Cc: gcc_bugs <gcc-bugs at gcc dot gnu dot org>, Zack Weinberg <zack at codesourcery dot com>
- Date: Sun, 4 Aug 2002 16:20:48 +0100
- Subject: Re: macro __VAR_ARGS_ bug??
- References: <3D4C7946.6261224E@linisoft.com>
Reza Roboubi wrote:-
> According to these documents:
> http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
> http://gcc.gnu.org/gcc-3.1/c99status.html
>
> it seems fairly clear that the following command
>
> >> gcc test.c -Wall -E
>
> when test.c is as follows:
>
> #define eprintf(format , ...) fprintf (stderr, format , ## __VA_ARGS__)
> eprintf ("success!\n",)
>
> should NOT produce the following output:
>
> fprintf (stderr, "success!\n")
>
> but that there should be an extra comma in the output, like this:
>
> fprintf (stderr, "success!\n",)
>
> I am using gcc 3.1 and I'm getting the incorrect output. Am I doing
> something wrong or is this a bug?
The behaviour you expect does seem to be what is documented, but hasn't
been the implementation since around Sep 2000. I think it did behave
the documented way just before then.
Zack, is there a good reason for the documented behaviour (where
no argument eats the comma, but an empty argument doesn't)? At present,
both are eating the comma.
If so, it shouldn't be too hard to fix.
Neil.