▲ | kazinator 4 days ago | |||||||
There is no "compiler", "IDE" or "include path" in the wording of the ISO C standard. A set of files is somehow presented to the implementation in a way that is not specified. Needless to say, a file that is included like "globals.h" but is not the base file of a translation unit will not be indicated to the implementation as the base of a translation unit. Nevertheless it has to be somehow present, if it is required. It doesn't seem as if you're engaging with the standard-based point I've been making, in spite of detailed elaboration. > Any header files shown there are not treated differently by the compiler/preprocessor to any others. This is absolutely false. Headers which are part of the implementation, such as standard-defined headers like <stdlib.h> need not be implemented as files. When the implementation processes #include <stdlib.h>, it just has to flip an internal switch which makes certain identifiers appear in their respective scopes as required. For that reason, if an implementation provides <winkle.h>, there need not be such a file anywhere in its installation. | ||||||||
▲ | quietbritishjim 3 days ago | parent [-] | |||||||
I only discussed things like include directories and IDEs, which are not part of the standard, because I am trying in good faith to understand how you could have come to your position. There is nothing in the standard like the "set of files is somehow presented to the implementation" (in a sense that includes header files) so I reasoned that maybe you were thinking of something outside the standard. Instead, the standard says that the include directive: > searches a sequence of implementation-defined places for a header ... and causes the replacement of that directive by the entire contents of the header. (Note that it talks about simply substituting in text, not anything more magical, but that's digressing.) It's careful to say "places" rather than "directories" to avoid the requirement that there's an actual file system, but the idea is the same. You don't pass the implementation every individual file that might need to be included, you pass in the places that hold them and a way to search them with a name. Maybe you were confused by that part of the standard you quoted in an earlier comment. One part of that says "The text of the program is kept in units called source files, (or preprocessing files) in this document." But the "source files" aren't really relevant to the include directive – those are the top-level files being compiled (what you've called "base files"). The next sentence you quoted says "A source file together with all the headers and source files included via the preprocessing directive #include is known as a preprocessing translation unit." But "all the headers" here is just referring to files that have been found by the search mechanism referred to above, not some explicit list. | ||||||||
|