[SDL] Demo glitch

Daniel Phillips phillips at arcor.de
Wed Jan 22 16:32:02 PST 2003


On Thursday 23 January 2003 00:32, Atrix Wolfe wrote:
> yep...
>
> <> makes the compiler look in the standard include directories (where
> stdio.h  etc is).
>
> "" is used for custom include directories  (dependant on compiler
> settings). If you set /include/sdl (whatever your include path is + /sdl/)
> to be a custom include path, "sdl.h" will be found there.

Sorry, this isn't accurate.  You will see here:

   http://www.lysator.liu.se/c/rat/c8.html#3-8-2

that the ISO committee wimps out and leaves the difference between #include 
<filename> and #include "filename" as implementation defined, but says that 
the implementation should correspond as closely as possible to the original 
intention of K&R.

So, pulling my K&R down off the shelf, I see this:

   A compiler line of the form

      #include "filename"

   causes the replacement of that line by the entire contents of the file 
   filename.  The named file is searched for first in the directory of the 
   original source file, and then in a swquence of standard places.   
   Alternatively, a control line of the form 

      #include <filename>

   searches only the standard places, and not the directoryt of the source 
   file.

So, to put it simply, the only difference between #include "filename" and 
#include <filename> is that the second one does not search the directory of 
the original source file before it searches other places.

We can then go on to observe that no sane person would put the SDL headers in 
the same directory as their project files, and therefore the claim in the FAQ 
about the #include "filename" form being more portable is most certainly 
wrong.

Finally, it's not your fault for being confused about this, it's the fault of 
a standardization process that does not think it is important to make the 
resulting documents publicly and freely available, so that people will refer 
to them when questions like this arise instead of guessing or relying on 
lore.  Note that the link I supplied is to a "rationale", not the actual 
standard.  You can also find "drafts" of the ISO C standard online if you 
look hard enough.  But to see the standard itself, you have to pay for it, 
which sounds like a good idea until you realize that that little obstacle is 
enough to keep 99.99% of programmers from ever looking at it, which rather 
dilutes the purpose of having a standard in the first place.

Takeaways:

  - the FAQ is wrong in its statement re portability

  - the only difference between the two forms in practice is that the
    quoted form searches the original source directory before searching the 
    same places as the other form (and whoever came up with this syntax was
    smoking something).

  - ISO should be publicly funded in its standardization work, and thus
    be able to distribute its work widely to help prevent confusion like
    this.

Regards,

Daniel




More information about the SDL mailing list