Liste des Groupes | Revenir à cl c |
On 2024-03-12, bart <bc@freeuk.com> wrote:
It's confusing. So "string.h" means the standard header, so it is the same as <string.h>, unless it happens to find a file called string.h amongst the project files.I tried my C compiler with a couple of open source projects recentlyIn the TXR project, I have a "signal.h" header, which must not resolve
that both failed for the same mysterious reason.
>
It turned out that one of them used this line:
>
#include "string.h"
>
and the other used:
>
#include "malloc.h"
to <signal.h>. I also have "time.h" and "termios.h", "glob.h",
"regex.h", "alloca.h".
Choosing header names that are distinct from an implementation's
headers is:
1) unnecessary due the local-first search strategy of #include "..."
2) a fool's errand.
Regarding (2), no name that you choose is guaranteed not to be identicalThe C implementation? Surely that will list all the system headers that it provides; it looks quite easy to avoid a clash!
to something in the implementation! Suppose I panic and rename
my "time.h" to "foo.h". Who is to say that some implementation doesn't
have a <foo.h> header?
There is no such rule that when you name a "whatever.h", you mustYou mean that programs should be allowed to do this:
ensure there does not exist a <whatever.h>.
So, is that /your/ file termios.c, or the one that implements the POSIX termios code?People like reusing the same popular module names so much, they willSometimes deliberately so. Why did I call that header "termios.h"
even use the names of standard headers!
is that the module is relates to is related to the POSIX termios;
the source file is called termios.c and includes <termios.h> as
well as its own "termios.h". This makes things readable; someone
looking at the directory listing can guess that these files
constitute a module which wraps termios.
Any other naming would obscure that to some degree, other than
perhaps longer names that contain "termios" as a substring.
Les messages affichés proviennent d'usenet.