Possible variadic macro bug

Peter Seebach seebs@plethora.net
Fri Nov 2 07:23:00 GMT 2001


Just a side question:

If the spec were some day revised to say that
	#define foo (a, ...) bar(a, __VA_ARGS__)
	foo(a)
	foo(b, c)
produced
	bar(a)
	bar(b, c)
would this be a big problem for gcc?  Essentially, this removes the ## before
the comma, and is otherwise (so far as I can tell) equivalent to what you're
doing.  We have draft wording floating around that would allow the ", ..." to
be ommitted in calls to variadic macros.

The reason I ask is that a couple of people have objected to the ", ##" as
being ugly (which I grudgingly grant that it is), and it seems to me that
the above change cannot break any currently-conforming code, and always does
what the user meant.  The formal wording would state that a comma preceeding
__VA_ARGS__ is omitted if __VA_ARGS__ is empty.  I don't think anyone ever
wants the comma in that case.

When this gets written up, I'd like to present both alternatives, in the hopes
of increasing the chance that *something* gets done.  I'd sort of prefer the
existing GNU C solution in terms of prior art, but I don't really like the
visual effect of ",##".

-s



More information about the Gcc-bugs mailing list