Directory search sequence for include files

The XL C compiler supports the following types of include files:
You can use any of the following methods to include any type of header file:

If you specify the header file using a full (absolute) path name, you can use these methods interchangeably, regardless of the type of header file you want to include. However, if you specify the header file using a relative path name, the compiler uses a different directory search order for locating the file depending on the method used to include the file.

Furthermore, the -qidirfirst and -qstdinc compiler options can affect this search order. The following summarizes the search order used by the compiler to locate header files depending on the mechanism used to include the files and on the compiler options that are in effect:
  1. Header files included with -qinclude only: The compiler searches the current (working) directory from which the compiler is invoked.1
  2. Header files included with -qinclude or #include "file_name": The compiler searches the directory in which the including file is located.1
  3. All header files: The compiler searches each directory specified by the -I compiler option, in the order that it displays on the command line.
  4. All header files: The compiler searches the standard directory for the XL C headers. The default directory for these headers is specified in the compiler configuration file. This is normally /opt/IBM/xlc/13.1.0/include. But the search path can be changed with -qc_stdinc compiler option.
  5. All header files: The compiler searches the standard directory for the system headers. The default directory for these headers is specified in the compiler configuration file. This is normally /usr/include/. But the search path can be changed with -qc_stdinc .
Note:
  1. If the -qidirfirst compiler option is in effect, step 3 is performed before steps 1 and 2.
  2. If the -qnostdinc compiler option is in effect, steps 4 and 5 are omitted.
Related information