Sujet : Re: C23 thoughts and opinions - why so conservative?
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.cDate : 24. May 2024, 17:22:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240524192256.00006890@yahoo.com>
References : 1 2 3 4 5
User-Agent : Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
On Fri, 24 May 2024 17:57:35 +0200
David Brown <
david.brown@hesbynett.no> wrote:
I can't say I have ever seen it as an effort. Almost all my C
"modules" come in pairs - "file.h" and "file.c". All non-local
variables (and all functions) are either static and declared only in
"file.c", or they are externally linked and have an "extern"
declaration in "file.h" and a definition (with or without
initialisation) in "file.c" (which #includes "file.h"). It is a very
simple and clean arrangement, easily checked by gcc warnings, and
there are never any undetected conflicts.
Declaration/definition pair is repeating yourself, which is not a good
think.
Of course, the same applies to declaration/definition of externally
visible functions, but somehow in case of functions I am more tolerant
to repetitions than in case of variable. Probably, a psychological
phenomenon - I feel that functions are less trivial, so repetition is
less wasteful.
But I'd like to get rid of these repetitions to, I just did not figure
out a way to do it that does not compromise even more important concern
of seperation between interface and implementation (yes, I dislike Java
for that reason too).