The first line of our sample program was:
#include <stdio.h>The format of that directive is the one you should use to include any of the standard header files that are supplied with the C compilation system. The angle brackets (< >) tell the preprocessor to search for the header file in the standard place for header files on your system, usually the /usr/include directory.
The format is different for header files that you have stored in your own directories:
#include "header.h"The double quotes (" ") tell the preprocessor to search for header.h first in the directory of the file containing the
#includeline, which will usually be your current directory, then in the standard place.
If your header file is not in the current directory, specify the path of the directory in which it is stored with the -I option to cc. For instance, if you have included both stdio.h and header.h in the source file test.c:
#include <stdio.h> #include "header.h"and header.h is stored in the directory ../defs, the command:
$will direct the preprocessor to search for header.h first in the current directory, then in the directory ../defs, and finally in the standard place. It will also direct the preprocessor to search for stdio.h first in ../defs, then in the standard place. The only difference is that the current directory is searched only for header files whose name you have enclosed in quotation marks.
cc -I../defs test.c
You can specify the -I option more than once on
the cc command line.
The preprocessor searches the specified directories in
the order they appear on the
You can therefore specify
multiple options to
on the same command line:
$ cc -o prog -I../defs test.c