Next: , Previous: , Up: MFL   [Contents][Index]

4.2 #include and #include_once

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:

  1. #include <file>
  2. #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:

  1. prefix/share/mailfromd/include
  2. prefix/share/mailfromd/9.0/include

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

  1. /var/mailfromd
  2. /com/mailfromd
  3. prefix/share/mailfromd/include
  4. prefix/share/mailfromd/9.0/include

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.

Next: , Previous: , Up: MFL   [Contents][Index]