Liste des Groupes | Revenir à cl c |
On Fri, 4 Apr 2025 02:57:10 -0000 (UTC)
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>On Thu, 3 Apr 2025 21:48:40 +0100, bart wrote:>
>Commas are overwhelmingly used to separate list elements in>
programming languages.
Not just separate, but terminate.
I disagree. I am in favor of optional trailing commas rather than
mandatory ones.
>All the reasonable languages allow>
trailing commas.
Are your sure that C Standard does not allow trailing commas?
That is, they are obviously legal in initializer lists.
All compilers that I tried reject trailing comma in function calls.
>
For example
>
void bar(int);
void foo(void) {
bar(1,);
}
>
MSVC:
comma.c(3): error C2059: syntax error: ')'
>
clang:
comma.c:3:9: error: expected expression
3 | bar(1,);
| ^
>
gcc:
comma.c: In function 'foo':
comma.c:3:9: error: expected expression before ')' token
3 | bar(1,);
| ^
comma.c:3:3: error: too many arguments to function 'bar'
3 | bar(1,);
| ^~~
comma.c:1:6: note: declared here
1 | void bar(int);
| ^~~
>
But is it (rejection) really required by the Standard? I don't know.
Les messages affichés proviennent d'usenet.