This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Possible variadic macro bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Possible variadic macro bug
- From: seebs at plethora dot net (Peter Seebach)
- Date: Fri, 09 Nov 2001 16:23:54 -0600
- Reply-To: seebs at plethora dot net (Peter Seebach)
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__)
In fact, the second seems to omit __LINE__ when there are no args in '...'.
This is tested with gcc 2.95.3.
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.)
-s