INCDIR (Include Directory) Command Parameter
The Include Directory parameter (INCDIR) works with the Create Module and Create Bound Program compiler commands, allowing you to redefine the path used to locate include header files (with the #include directive) when compiling a source stream file only. The parameter is ignored if the source file's location is not defined as an IFS path via the Source Stream File (SRCSTMF) parameter, or if the full (absolute) path name is specified on the #include directive.
The parameter accepts a list of IFS directories. These directories are inserted into the include search path in the order they are entered.
The include files search path adheres to the following directory
search order to locate the file:
#include type | Directory Search Order |
---|---|
#include <file_name> |
|
#include "file_name" |
|
For example, if you enter the following value for the INCDIR parameter:
Include directory . . . . . . . INCDIR '/tmp/dir1'
+ for more values './dir2'
and with your source stream file you include the following
header files: #include "foo.h"
#include <stdio.h>
The compiler first searches for a file "foo.h" in the
directory where the root source file resides. If the file is found,
it is included and the search ends. Otherwise, the compiler searches
the directories entered INCDIR, starting with "/tmp/dir1". If the
file is found, this file is included. If the directory does not exist,
or if the file does not exist within that directory, the compiler
continues to search in the subdirectory "dir2" within the current
working directory (symbolized by "."). Again, if the file is found,
this file is included, otherwise, because the directories in INCDIR
path have now been exhausted, the default user include path (/QIBM/include)
is used to find the header.As for <stdio.h>
, the same logic is followed
in the same order, except the initial search in the root source directory
is bypassed.