Old Wolf wrote:
On Nov 13, 12:46 pm, "(e-mail address removed)" <
[email protected]>
#define D(y...) (const int []) {y}
There are actually two things in the above which cause syntax
errors in current C++. The first is that it is a variadic
macro, which is legal in C99 and will be legal in the next
version of C++.
Variadic macros in C99 look like:
i.e. the ellipsis is separated from the other
arguments by a comma (with optional whitespace).
So I see. I wonder why they didn't support the form without the
comma, as they do in function declarations. Shocking lack of
orthogonality.
(Historically, the comma wasn't allowed in function
declarations; the syntax was exactly that of a natural language,
where you would never write "a, b, ..." but always "a, b...".
When C adopted this syntax from C++, the C committee decided to
allow the syntax with the comma as well; I'm not sure what their
reasoning was, but I also find it more appealing, separating the
.... from the preceding argument. But not enough more appealing
to have justified changing or extending the existing
specification; if it were a new invention, I'd define it with
the comma, but since it wasn't, and isn't, I don't think that
there was, or is, sufficient justification to add the form with
the comma.)
The ellipsis directly following the argument name, isn't in
any C standard. (Another poster suggests that it's a GCC
extension).
Might be. I would certainly expect that most implementations
supporting vararg templates support it (except maybe in their
strictest modes), much like they support a final comma in an
enum list. There is absolutely no reason not to be orthogonal
here (and I would consider this a defect in the C standard).