This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Possible variadic macro bug
- To: Peter Seebach <seebs at plethora dot net>
- Subject: Re: Possible variadic macro bug
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: Fri, 9 Nov 2001 22:36:34 +0000
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <200111092223.fA9MNsb15393@guild.plethora.net>
Peter Seebach wrote:-
> These macros should, IMHO, do the same thing:
>
> #define panic(x,...) _panic(x, __FILE__ , __LINE__ , ## __VA_ARGS__)
> #define panic(x,...) _panic(x, __FILE__ , __LINE__, ## __VA_ARGS__)
They do in 3.0. But have you read the 2.95.3 manual? You would see
there that, in that version, this use of ## is whitespace-sensitive
(daft for what is supposed to be a tokenized preprocessor, I know).
> In fact, the second seems to omit __LINE__ when there are no args in '...'.
>
> This is tested with gcc 2.95.3.
See above.
> While I'm at it, the documentation for ISO's __VA_ARGS__ in extend.texi
> is misleading. While it's true that, given
> #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
> you can't omit the comma, you *could* write
> #define debug(format ...) fprintf(stderr, format __VA_ARGS__)
> in C99, and then the comma is optional. (See 6.10.3, paragraph 10, for
> the description.)
Have you tried it?
Neil.