3.1.3 Include files

If you include a file in your source with the {$I filename} directive, the compiler will look for it in the following places:

  1. It will look in the path specified in the include file name.
  2. It will look in the directory where the current source file is.
  3. it will look in all directories specified in the include file search path.

You can add files to the include file search path with the -I (see page 5.1.3) or -Fi (see page 5.1.3) options.

As an example, consider the following include statement in a file units/foo.pp:

 
{$i ../bar.inc}  

Then the following command :

fpc -Iincfiles units/foo.pp

will cause the compiler to look in the following directories for bar.inc:

  1. The parent directory of the current directory.
  2. The units subdirectory of the current directory.
  3. The incfiles subdirectory of the current directory.