Sujet : Re: Which code style do you prefer the most?
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 12. Mar 2025, 06:11:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86cyemu931.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Richard Heathfield <
rjh@cpax.org.uk> writes:
On 28/02/2025 12:19, Michael S wrote:
>
On Fri, 28 Feb 2025 10:24:19 +0000
Richard Heathfield <rjh@cpax.org.uk> wrote:
>
On 28/02/2025 09:22, David Brown wrote:
>
As long as it's not "Long time no C" :-)
>
I'm afraid it is. Nowadays I spend most of my time arguing with
\LaTeX, although when I do cut code it is in C (and that's proper
C, of course, not this newfangled gibberish).
>
one man's newfangled gibberish is another man's proper C
>
Agreed. On the other hand, it is easy to overlook the virtue of
stability, and change does not necessarily imply progress.
C is quite stable in the sense that in most cases C90 code is
acceptable under C99 or C11 rules. I think there are four kinds
of differences that someone might want to avoid.
One, some C90 features were removed from C99. The obvious
examples are implicit 'int' type and implicit function
declaration.
Two, some constructs are allowed in both C90 and C99 but have
different semantics, or possibly different semantics. One
example is what precision is used in expressions evaluated in the
C preprocessor. Another example is integer division, which is
well-defined in C99 but only implementation-defined in C90.
Three, in some cases code that is legal in C90 is not legal in
C99 (and not because features are just removed as in case one).
The most obvious examples involve the use of new keywords such as
'inline' and 'restrict' as ordinary identifiers.
Four, use of constructs that are newly allowed in C99 and are
(obviously) legal under C99 rules but would cause diagnostics
under C90 rules. An example is allowing a trailing comma in
definitions of 'enum' types. If someone were to want non-C90
code (even only certain non-C90 constructs) to be given a
diagnostic then obviously using C99 or later would prevent that.
Are any of these cases ones that you find objectionable or would
cause difficulty for code that you work on? If so which ones?
My question here is meant to ask about specifics, not just
general categories. And to be clear, I don't mean to limit the
set of potential problems being considered to just the examples
given above.