[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU coding standards
From: |
Bruno Haible |
Subject: |
Re: GNU coding standards |
Date: |
Wed, 09 Oct 2024 17:52:04 +0200 |
Alfred M. Szmidt wrote:
> the chapter on K&R C is a suggestion if you need
> to support it so there is no harm in having it included.
I agree with Martin:
* K&R C compilers (i.e. compilers that don't support ANSI C from 1989)
are not in use any more. In Gnulib, we have dropped support for such
compilers in 2011, and no one complained.
* The most recent gcc and clang compilers, when used with option -std=gnu23,
warn about K&R C functions definitions:
==================== foo.c ===================
int foo (x, y) int x; int y; { return x - y; }
==============================================
$ gcc -std=gnu23 -S foo.c
foo.c: In function ‘foo’:
foo.c:1:5: warning: old-style function definition
[-Wold-style-definition]
1 | int foo (x, y) int x; int y; { return x - y; }
| ^~~
$ clang -std=gnu23 -S foo.c
foo.c:1:10: error: unknown type name 'x'
1 | int foo (x, y) int x; int y; { return x - y; }
| ^
foo.c:1:13: error: unknown type name 'y'
1 | int foo (x, y) int x; int y; { return x - y; }
| ^
foo.c:1:15: error: expected ';' after top level declarator
1 | int foo (x, y) int x; int y; { return x - y; }
| ^
| ;
foo.c:1:30: error: expected identifier or '('
1 | int foo (x, y) int x; int y; { return x - y; }
| ^
This option -std=gnu23 will become the default in the future, like
-std=gnu99 and later -std=gnu11 became the default.
Therefore the harm of this section is that it suggests a code style
that we know is not future-proof.
Bruno
- GNU coding standards, Martin D Kealey, 2024/10/08
- Re: GNU coding standards, Alfred M. Szmidt, 2024/10/09
- Re: GNU coding standards,
Bruno Haible <=
- Re: GNU coding standards, Collin Funk, 2024/10/09
- Re: GNU coding standards, Alfred M. Szmidt, 2024/10/09
- Re: GNU coding standards, Arsen Arsenović, 2024/10/09
- Re: GNU coding standards, Alfred M. Szmidt, 2024/10/10
- Re: GNU coding standards, Arsen Arsenović, 2024/10/13
- Re: GNU coding standards, Alfred M. Szmidt, 2024/10/13
- Re: GNU coding standards, Arsen Arsenović, 2024/10/14
- Re: GNU coding standards, Richard Stallman, 2024/10/16
- Re: GNU coding standards, Arsen Arsenović, 2024/10/19
- Re: GNU coding standards, Martin D Kealey, 2024/10/13