Is there a difference in these two declarations?
int foo( int a, ... );
and
int foo( int a ... );
If there is no difference, what was the point of making the second syntactically valid?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is speculation, but in C++ in can make sense to have a function with no other parameters, e.g.
void f(...)whereas in C a function like this has no use (that I know of) so...must follow some other parameter and hence, a comma.From a grammar point of view, it’s simpler to simply allow
void f( int a ... )and give it the obvious meaning than it is to disallow it and it’s not going to cause much of a burden on compiler writers or any confusion for programmers.(I originally thought it might be something to do with making the grammar for parameter packs more regular but I discovered that it was explicitly allowed in C++03 in any case.)