All, >> Shouldnt it be that #include "foo.h" is from the current directoy and >> #include <bar.h> is from "$COMPILER_DIR/include" (or /usr/include in >> gcc's case...)? > > That is a common implementation, but not defined anywhere in the > standard. That's true, but the exact wording of C99 (porbably older standards, too) "sounds" like a suggestion for the way many compilers (see below) do it: "A preprocessing directive of the form # include <h-char-sequence> new-line searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters" [...] "A preprocessing directive of the form # include "q-char-sequence" new-line causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters." "Example:" "The most common uses of #include preprocessing directives are as in the following: #include <stdio.h> #include "myprog.h" " However, both of these "places" and "search" are implementation defined. As Uz wrote already, many widely used compilers define the "sequence of implementation-defined places" as system include paths, these (and paths from command line) are searched first when <> ist used. On the other hand ""-files are searched in the same directory as the current file. More details about special cases can be found in their manuals, for example: http://gcc.gnu.org/onlinedocs/gcc-4.4.2/cpp/Include-Syntax.html#Include-Syntax http://msdn.microsoft.com/en-us/library/aa273929(VS.60).aspx http://www.openwatcom.org/ftp/manuals/current/cguide.pdf (Chapter 3.7) > But the actual question was, how "current directory" is defined. Is > it the current directory where the compiler was started? Or the > directory where the file lives, that contains the include statement? AFAIR the latter is how GCC does it. It's also sane in my opinion, because a) the source code contains the semantic, not the Makefile b) directory structures like $project/src $project/include are quite common Spriro wrote: > In the case for the ISO standard, there is no mentioning of it. The > standard does not even know about directories. It's called "places" there, this also allows e.g. in-memory header files. Slightly OT: > Hopefully, not in the "C-Tutorial" on F-64 that does not teach C, but > something different that has just some similarity to C? ;) I feel like you refer to my tutorial http://skoe.de/wiki/doku.php?id=sidebar If this is true, you are welcome to tell me about the thing's you don't like. Maybe better not in this list, because it's OT. _Several_ experienced (15+ years) C programmers reviewed that tutorial and improved it. When being in doubt we tried to stick as close as possible to ISO. And we tried to keep it simple for beginners while avoiding incorrect simplifications where possible. So if you can improve it or at least tell what is wrong in your eyes, feel free to tell it. Otherwise don't make fun of other peoples' work, because that's just "something different" than criticism from an educated person. Thomas ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Mon Jan 18 20:06:56 2010
This archive was generated by hypermail 2.1.8 : 2010-01-18 20:06:59 CET