Sujet : Re: Word For Today: “Uglification”
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 13. Mar 2024, 13:45:31
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uss3kr$ud17$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Mozilla Thunderbird
On 12/03/2024 23:00, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
That is undesirable, unless you specifically want to shadow the
standard headers. In the examples I saw, that was not the case.
You didn't mention that. If you'd tell us what project you're talking
about, maybe we could discuss it. Perhaps
That's not really relevant. Suffice that they are amateur projects and clearly they were using using string.h etc for their own purposes without thinking.
Read section 6.10.2 of the standard. It describes the search rules for
the #include directive.
Not in N1570 it doesn't. It seems mainly concerned with the syntax.
I understand that the algorithm for finding include files was implementation-defined, and typically depended on these inputs:
* Whether the filename used "..." or <...>
* Whether the file-name specified was absolute or relative
* The path of the source file in which the #include occurs
* Possibly, the complete stack of paths for the current sequence set of
nested #includes
* Possibly, on the CWD
* On where the compiler keeps its standard headers (which in turn may
depend on OS)
* On the set of -I directives given to the compiler (this is
something outside the remit of the standard, AIUI)
To summarize, #include <foo.h> searches for a header (probably but not
necessarily a file) identified by foo.h. #include "foo.h" searches for
a *file* called foo.h, and if that fails it then searches for a header
identified by <foo.h>. The sequences for both searches are
implementation-defined.
This is something new I saw today: suppose I have hello.c in a directory (hello.c uses '#include <stdio.h>').
If I create an empty file called 'stdio.h', then 4 compilers I tried all picked up that file instead of their official stdio.h. That looks a dangerous practice to me.
It also seems, for a <...> file, to ignore the official repository and look first within the user's project. So what exactly is the difference between <...> and "..."? Is it just an extra set of backup paths to look if it can't find anything within the user's files?
(The 5th compiler I tried ignored it and worked as normal; that was mine. I can make it fail using my '-ext' option to look elsewhere than the official headers location. I don't make a distinction between <...> and "...".)