Re: Official list of top C annoyances

Liste des GroupesRevenir à l c 
Sujet : Re: Official list of top C annoyances
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 09. Sep 2026, 09:35:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <117r5p8$s9ir$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla Thunderbird
On 09/09/2026 09:59, Janis Papanagnou wrote:
On 2026-09-08 09:25, David Brown wrote:
On 08/09/2026 00:50, Janis Papanagnou wrote:
>
It's even worse; given - as mentioned in another part of the thread -
that #includes are costly we often find some means to avoid not only
duplicated includes (by #ifndef LABEL, #define LABEL, ..., #endif)
in the header files but also to prevent accessing the header file in
the first place (by #ifndef LABEL, #include <label.h>, #endif). That
makes such C/C++ code rather messy, IMO. (And makes one appreciate
languages with an inherent good modularization method yet more.)
>
It is almost universal practice to have such include guards in header files.
 Yeah, that was also my suspicion. (Though I'm not any more practically
involved in professional C/C++ development so I'm not really up to date
what additional options we nowadays have.)
 
("#pragma once" is also often used, but while most compilers support it, it is not standard and it can be problematic in some circumstances.)  The norm is to have the include guard cover everything except perhaps some comments at the head of the file, and compilers have fast paths to handle such discarded includes very efficiently.
>
So I would not count include guards as a problem in C - think of it more as a quirky syntax for how header files are written.
 Well, I wouldn't actually call it a "problem". - I mean, it's "C" we're
talking about. :-)
 Yes, the syntax (and all the overhead) is what I find annoying. (But
I'm used to it, and it's also not worth complaining. It's effective.)
 
Where other languages might have "interface module XXX;", C has "#ifndef __XXX__".
 I'm not feeling competent enough concerning "the best" module interface
methods and their discussion, but I've met a handful languages/methods
during my IT life and the C/C++ "model" is rather at the low end. (But
I've also programmed in languages that didn't have any module-concept
at all. - We've to use what we are supposed to work with.)
 
There's no doubt that the C and C++ (prior to modules in C++20) headers are quite a primitive, low-level mechanism.  They are very flexible, and can be used for much more than a clear, rigid module system - but with that flexibility to do weird and wonderful things comes the flexibility to do strange, confusing, inefficient or simple incorrect things.  The same principle applies to the text-based macros of the C pre-processor. It requires discipline and convention to use well.
And that flexibility also leads to disadvantages when trying to change or improve things - any new solution still has to work with code that includes the same file multiple times intentionally (such as for so-called "x-macros"), or has headers whose functionality depends on macro definitions before inclusion, and so on.
Basically, if you are making a new language, you should include some kind of module system that is better than C has - but it is impractical to try to change C now.  (Maybe C could later copy modules from C++, once there has been enough practical experience built up around them. But it would first have to copy namespaces.)

>
Still, there can be problems when someone does not follow the common practice here.
 We defined our company (coding-)standards to cover that. (And had our
technical mechanisms to alleviate the burden of the textual overhead.)
 
Most serious developers use some kind of IDE or advanced editor, and most such tools can generate include guards automatically when you create a new header file.

>
It is also inconvenient when a programmer fails to include sub- includes that are needed, so that the person using the header has to figure out a correct order and manually add any required include files.
 Hmm.. - I'm not sure I can follow you here. - If some of our headers
had its own dependencies it was the responsibility of that header to
satisfy them. - I recall there were occasionally issues with lacking
consistency, but that was in our project contexts considered a bug.
 
I follow that principle too.  But not everyone does.  So I would have :
#ifndef __NUMBER_GENERATOR_H__
#define __NUMBER_GENERATOR_H__ 1
#include <stdint.h>
extern uint64_t make_a_big_number(void);
#endif // #ifndef __NUMBER_GENERATOR_H__
But some people would omit the "#include <stdint.h>" line, and leave that as the responsibility of the person writing the C file.  The same applies to dependencies on local header files.

>
C's include system is not hard to use well, but it is certainly possible to use it badly and cause inconvenience to others.
 Yes. It's primitive. It does its job. And you should accompany their
use by standards and conventions.
 
Agreed.
(Of course that applies to a lot of aspects of C.  It's a language that requires more programmer responsibility than some other languages where the tools can do more checks at compile-time, or you have more checks at run-time.)

Date Sujet#  Auteur
6 Sep 26 * Official list of top C annoyances396fir
6 Sep 26 +- Re: Official list of top C annoyances1fir
6 Sep 26 +* Re: Official list of top C annoyances368bart
6 Sep 26 i+* Re: Official list of top C annoyances366Janis Papanagnou
7 Sep 26 ii+* Re: Official list of top C annoyances362fir
7 Sep 26 iii`* Re: Official list of top C annoyances361bart
7 Sep 26 iii +* Re: Official list of top C annoyances359David Brown
7 Sep 26 iii i`* Re: Official list of top C annoyances358bart
7 Sep 26 iii i +- Re: Official list of top C annoyances1fir
7 Sep 26 iii i `* Re: Official list of top C annoyances356David Brown
7 Sep 26 iii i  +* Re: Official list of top C annoyances354bart
7 Sep 26 iii i  i+* Re: Official list of top C annoyances65Janis Papanagnou
8 Sep 26 iii i  ii+* Re: Official list of top C annoyances24bart
8 Sep 26 iii i  iii+* Re: Official list of top C annoyances6Lane W
8 Sep 26 iii i  iiii`* Re: Official list of top C annoyances5Keith Thompson
9 Sep 26 iii i  iiii `* Re: Official list of top C annoyances4fir
9 Sep 26 iii i  iiii  `* Re: Official list of top C annoyances3fir
9 Sep 26 iii i  iiii   `* Re: Official list of top C annoyances2fir
18 Sep08:38 iii i  iiii    `- Re: Official list of top C annoyances1fir
8 Sep 26 iii i  iii+- Re: Official list of top C annoyances1Janis Papanagnou
8 Sep 26 iii i  iii`* Re: Official list of top C annoyances16bart
9 Sep 26 iii i  iii +- Re: Official list of top C annoyances1Janis Papanagnou
9 Sep 26 iii i  iii `* Re: Official list of top C annoyances14David Brown
9 Sep 26 iii i  iii  `* Re: Official list of top C annoyances13bart
9 Sep 26 iii i  iii   `* Re: Official list of top C annoyances12David Brown
9 Sep 26 iii i  iii    `* Re: Official list of top C annoyances11bart
9 Sep 26 iii i  iii     `* Re: Official list of top C annoyances10David Brown
9 Sep 26 iii i  iii      `* Re: Official list of top C annoyances9bart
9 Sep 26 iii i  iii       +- Re: Official list of top C annoyances1bart
9 Sep 26 iii i  iii       +* Re: Official list of top C annoyances3David Brown
9 Sep 26 iii i  iii       i`* Re: Official list of top C annoyances2bart
10 Sep 26 iii i  iii       i `- Re: Official list of top C annoyances1David Brown
9 Sep 26 iii i  iii       +* Re: Official list of top C annoyances2Janis Papanagnou
9 Sep 26 iii i  iii       i`- Re: Official list of top C annoyances1Janis Papanagnou
9 Sep 26 iii i  iii       `* Re: Official list of top C annoyances2Keith Thompson
9 Sep 26 iii i  iii        `- Re: Official list of top C annoyances1bart
8 Sep 26 iii i  ii`* Re: Official list of top C annoyances40David Brown
9 Sep 26 iii i  ii `* Re: Official list of top C annoyances39Janis Papanagnou
9 Sep 26 iii i  ii  `* Re: Official list of top C annoyances38David Brown
9 Sep 26 iii i  ii   +* Re: Official list of top C annoyances7Janis Papanagnou
9 Sep 26 iii i  ii   i`* Re: Official list of top C annoyances6David Brown
10 Sep 26 iii i  ii   i `* Re: Official list of top C annoyances5Chris M. Thomasson
10 Sep 26 iii i  ii   i  +- Re: Official list of top C annoyances1Chris M. Thomasson
11 Sep 26 iii i  ii   i  +- Re: Official list of top C annoyances1David Brown
14 Sep 26 iii i  ii   i  `* Re: Official list of top C annoyances2Kaz Kylheku
18 Sep16:29 iii i  ii   i   `- Re: Official list of top C annoyances1Tim Rentsch
9 Sep 26 iii i  ii   `* Re: Official list of top C annoyances30Keith Thompson
9 Sep 26 iii i  ii    +* Re: Official list of top C annoyances26David Brown
9 Sep 26 iii i  ii    i`* Re: Official list of top C annoyances25Lane W
9 Sep 26 iii i  ii    i +* Re: Official list of top C annoyances23David Brown
9 Sep 26 iii i  ii    i i+* Re: Official list of top C annoyances8Lane W
9 Sep 26 iii i  ii    i ii+* Re: Official list of top C annoyances6fir
9 Sep 26 iii i  ii    i iii+* Re: Official list of top C annoyances3Lane W
9 Sep 26 iii i  ii    i iiii+- Re: Official list of top C annoyances1fir
10 Sep 26 iii i  ii    i iiii`- Re: Official list of top C annoyances1Keith Thompson
9 Sep 26 iii i  ii    i iii`* Re: Official list of top C annoyances2fir
9 Sep 26 iii i  ii    i iii `- Re: Official list of top C annoyances1fir
9 Sep 26 iii i  ii    i ii`- Re: Official list of top C annoyances1David Brown
9 Sep 26 iii i  ii    i i+* Re: Official list of top C annoyances13bart
9 Sep 26 iii i  ii    i ii`* Re: Official list of top C annoyances12Lane W
9 Sep 26 iii i  ii    i ii +* Re: Official list of top C annoyances9bart
9 Sep 26 iii i  ii    i ii i+* Re: Official list of top C annoyances6fir
9 Sep 26 iii i  ii    i ii ii+* Re: Official list of top C annoyances4fir
9 Sep 26 iii i  ii    i ii iii`* Re: Official list of top C annoyances3fir
9 Sep 26 iii i  ii    i ii iii `* Re: Official list of top C annoyances2fir
9 Sep 26 iii i  ii    i ii iii  `- Re: Official list of top C annoyances1fir
9 Sep 26 iii i  ii    i ii ii`- Re: Official list of top C annoyances1fir
9 Sep 26 iii i  ii    i ii i+- Re: Official list of top C annoyances1bart
10 Sep 26 iii i  ii    i ii i`- Re: Official list of top C annoyances1David Brown
9 Sep 26 iii i  ii    i ii +- Re: Official list of top C annoyances1David Brown
9 Sep 26 iii i  ii    i ii `- Re: Official list of top C annoyances1Keith Thompson
10 Sep 26 iii i  ii    i i`- Re: Official list of top C annoyances1Janis Papanagnou
9 Sep 26 iii i  ii    i `- Re: Official list of top C annoyances1Keith Thompson
9 Sep 26 iii i  ii    `* Re: Official list of top C annoyances3Richard Harnden
9 Sep 26 iii i  ii     +- Re: Official list of top C annoyances1Keith Thompson
10 Sep 26 iii i  ii     `- Re: Official list of top C annoyances1Janis Papanagnou
8 Sep 26 iii i  i`* Re: Official list of top C annoyances288Waldek Hebisch
8 Sep 26 iii i  i `* Re: Official list of top C annoyances287bart
9 Sep 26 iii i  i  +* Re: Official list of top C annoyances269Waldek Hebisch
9 Sep 26 iii i  i  i+- Re: Official list of top C annoyances1Janis Papanagnou
9 Sep 26 iii i  i  i`* Re: Official list of top C annoyances267bart
9 Sep 26 iii i  i  i +- Re: Official list of top C annoyances1tTh
9 Sep 26 iii i  i  i +* Re: Official list of top C annoyances3David Brown
9 Sep 26 iii i  i  i i`* Re: Official list of top C annoyances2bart
10 Sep 26 iii i  i  i i `- Re: Official list of top C annoyances1David Brown
9 Sep 26 iii i  i  i +* Re: Official list of top C annoyances121Janis Papanagnou
9 Sep 26 iii i  i  i i`* Re: Official list of top C annoyances120bart
10 Sep 26 iii i  i  i i +* Re: Official list of top C annoyances41Janis Papanagnou
10 Sep 26 iii i  i  i i i`* Re: Official list of top C annoyances40bart
10 Sep 26 iii i  i  i i i `* Re: Official list of top C annoyances39fir
10 Sep 26 iii i  i  i i i  +* Re: Official list of top C annoyances3fir
10 Sep 26 iii i  i  i i i  i`* Re: Official list of top C annoyances2fir
10 Sep 26 iii i  i  i i i  i `- Re: Official list of top C annoyances1fir
10 Sep 26 iii i  i  i i i  `* Re: Official list of top C annoyances35bart
10 Sep 26 iii i  i  i i i   +- Re: Official list of top C annoyances1fir
10 Sep 26 iii i  i  i i i   `* Re: Official list of top C annoyances33fir
10 Sep 26 iii i  i  i i i    +* Re: Official list of top C annoyances31bart
10 Sep 26 iii i  i  i i i    i+* Re: Official list of top C annoyances5fir
10 Sep 26 iii i  i  i i i    ii`* Re: Official list of top C annoyances4fir
10 Sep 26 iii i  i  i i i    ii `* Re: Official list of top C annoyances3bart
10 Sep 26 iii i  i  i i i    ii  `* Re: Official list of top C annoyances2fir
10 Sep 26 iii i  i  i i i    i`* Re: Official list of top C annoyances25fir
10 Sep 26 iii i  i  i i i    `- Re: Official list of top C annoyances1fir
10 Sep 26 iii i  i  i i `* Re: Official list of top C annoyances78David Brown
13 Sep 26 iii i  i  i `* Re: Official list of top C annoyances141Waldek Hebisch
9 Sep 26 iii i  i  `* Re: Official list of top C annoyances17Janis Papanagnou
8 Sep 26 iii i  `- Re: Official list of top C annoyances1Chris M. Thomasson
7 Sep 26 iii `- Re: Official list of top C annoyances1fir
7 Sep 26 ii`* Re: Official list of top C annoyances3David Brown
7 Sep 26 i`- Re: Official list of top C annoyances1Chris M. Thomasson
7 Sep 26 +- Re: Official list of top C annoyances1fir
8 Sep 26 `* Re: Official list of top C annoyances25fir

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal