Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> writes:
I didn't attempt to describe the algorithm, only to list the various variables.I understand that the algorithm for finding include files wasYes -- but you left out a major part of it, that if a search for a ""
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)
header fails, it continues by treating it as if it were a <> header.
My observations were erroneous. It turned out I'd been messing about with hello.c (when investigating these matters a few days ago) so that it was using "stdio.h" rather than <stdio.h>.If I create an empty file called 'stdio.h', then 4 compilers I triedIf they're behaving as you're describing, then they're not conforming.
all picked up that file instead of their official stdio.h. That looks
a dangerous practice to me.
I've tried gcc, clang, and tcc, and all pick up the correct <stdio.h>
header even if there's a "stdio.h" file in the current directory.
It's possible in principle that a compiler could include the current
directory in the <> search path, but that would be surprising, and none
of the compilers I've tried do so.
What are these 4 compilers? Are you sure you used <stdio.h> and not
"stdio.h"? Did you use any additional command line options? Might you
have set some environment variable like $C_INCLUDE PATH that affects the
behavior?
(The 5th compiler I tried ignored it and worked as normal; that wasPerhaps I'm missing something. If your compiler doesn't distinguish
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 "...".)
between <> and "", then #include "stdio.h" should be equivalent to
#include <stdio.h>. You say it ignores a stdio.h file in the current
directory. Then how can a source file include *any* header file in the
current directory?
#include <stdio.h> // This includes the system header.<...> are not special, but it knows which are the standard headers because there is a list of them in the compiler.
#include "stdio.h" // You say this ignores any local file and
// includes the system header.
#include "foo.h" // Does this not include a local file named "foo.h"?
Les messages affichés proviennent d'usenet.