bug-standards
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU coding standards


From: Martin D Kealey
Subject: GNU coding standards
Date: Tue, 8 Oct 2024 14:20:15 +1000

I note that section 3.4 of https://www.gnu.org/prep/standards/standards.html#Standard-C recommends that we continue to write K&R style function headers.

I am at a loss to understand how this section has remained intact for so long after it should have been removed. It's years - nay decades - past time when we should have been removing extant K&R function headers, not creating them.

The rationale given is this:
You need such a declaration anyway, in a header file, to get the benefit of prototypes in all the files where the function is called. And once you have the declaration, you normally lose nothing by writing the function definition in the pre-standard style.

The assertion of "normally lose nothing" is highly suspect:

Please can this section be excised or heavily revised? At minimum, could there be guidance added for projects that are intended for use in "general purpose computing platforms" that they should target a (much) newer version of the C standard such as C11, and that they should do so consistently. (Don't leave in a mix of new-style code and old-style work-arounds; settle on one or the other, and clean up any associated technical debt from time to time.)

If you need more reasons, consider:

Personally, I would go further, and declare at least C99 (or even C11) as the minimum target. Yes there are still some older platforms out there, but are they general purpose computing environments rather than specialized environments where code could be cross-compiled on a modern more capable platform?

There's significant loss of expressive power when targeting anything before C99, which results in worse maintainability:

Lastly, the importance of writing software so that it can run on non-standard platforms is overstated. The vast majority of devices run Linux (including Android), Windows, or Darwin, all of which have multiple C23 compilers available, as do other minor platforms such as FreeBSD or QNX.

-Martin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]