J
jacob navia
I have just noticed that I forgot to include an explanation of that in my tutorial.
I added the following. I hope I got the essentials corect. Note that this is a
tutorial, i.e. should be easy on the user...
Note that the standard says nothing about directories, so it is of no
help here.
1.34.1.6 The include directive
This directive instructs the preprocessor to read a file from disk and include its
text into the current position. All the text of the file is inserted into the compiler
input stream and preprocessed just as if you would have written exactly all that text
in the current position.
This directive has two variants:
The first uses angle brackets to enclose the name of the file to include.
#include <stdio.h>
The second uses quotes to enclose the file name:
#include "myfile.h"
The first one means that the preprocessor should look for the file in the system
include directory, where the files furnished by the implementation are stored.
The second means that the preprocessor looks first in the current directory for
the mentioned file. Note that the current directory starts as the one where the
first source file is stored, the one that the compiler receives as a parameter
when invoked. Of course, this can change later if you include a file in another
directory.
For instance:
You have a file in the current directory that has an include directive like:
#include "myincludes/decls.h"
And within decls.h you have an include directive like
#include "stddecls.h"
The preprocessor starts looking for stddecls.h in "myincludes", not in the
original directory.
I added the following. I hope I got the essentials corect. Note that this is a
tutorial, i.e. should be easy on the user...
Note that the standard says nothing about directories, so it is of no
help here.
1.34.1.6 The include directive
This directive instructs the preprocessor to read a file from disk and include its
text into the current position. All the text of the file is inserted into the compiler
input stream and preprocessed just as if you would have written exactly all that text
in the current position.
This directive has two variants:
The first uses angle brackets to enclose the name of the file to include.
#include <stdio.h>
The second uses quotes to enclose the file name:
#include "myfile.h"
The first one means that the preprocessor should look for the file in the system
include directory, where the files furnished by the implementation are stored.
The second means that the preprocessor looks first in the current directory for
the mentioned file. Note that the current directory starts as the one where the
first source file is stored, the one that the compiler receives as a parameter
when invoked. Of course, this can change later if you include a file in another
directory.
For instance:
You have a file in the current directory that has an include directive like:
#include "myincludes/decls.h"
And within decls.h you have an include directive like
#include "stddecls.h"
The preprocessor starts looking for stddecls.h in "myincludes", not in the
original directory.