If ‘#’ is followed by word ‘include’ (with optional whitespace between them), this statement requires inclusion of the specified file, as in C. There are two forms of the ‘#include’ statement:
#include <file>
#include "file"
The quotes around file in the second form quotes are optional.
Both forms are equivalent if file is an absolute file name. Otherwise, the first form will look for file in the include search path. The second one will look for it in the current working directory first, and, if not found there, in the include search path.
The default include search path is:
where prefix is the installation prefix.
New directories can be appended in front of it using -I
(--include-path) command line option, or include-path
configuration statement (see include-path).
For example, invoking
$ mailfromd -I/var/mailfromd -I/com/mailfromd
creates the following include search path
Along with #include
, there is also a special form
#include_once
, that has the same syntax:
#include_once <file> #include_once "file"
This form works exactly as #include
, except that, if the
file has already been included, it will not be included
again. As the name suggests, it will be included only once.
This form should be used to prevent re-inclusions of a code, which can cause problems due to function redefinitions, variable reassignments etc.