Sujet : Re: "A diagram of C23 basic types"
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.cDate : 09. Apr 2025, 10:49:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250409124900.00000fa1@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
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.