My program:
int main(){}
In upcoming C23, non-prototype and "K&R style" functions are removed. I realize that C23 is not yet formally released, but the current behavior of gcc and clang is confusing me.
- Compiling the above with gcc (trunk)
-std=c2x -pedantic-errors -Wall -Wextra:
no diagnostics. - Compiling the above with clang 16.0.0
-std=c2x -pedantic-errors -Wall -Wextra:
no diagnostics. - Compiling the above with clang 16.0.0
-pedantic-errors -Wall -Wextra:error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
How am I to make any sense of this? I can understand if gcc has not yet implemented this, since C23 is after all not yet released, but why is clang giving the warning when I don't specify -std=c2x?
When you use clang 16.0.0 and don't use
-std=c2xit defaults to some version that is not c2x (probably c11, maybe c17).In that version, your program has a
function declaration without a prototype, which isdeprecated in all versions of C(including that one).In C2X, they removed the possibility of declaring functions without prototypes. Every function declaration has a prototype. So this same code is a function declaration with a prototype with no parameters.