Directory search sequence for included files
The IBM® Open XL C/C++ compiler supports the following types of included files.
- Header files supplied by the compiler (referred to throughout this document as IBM Open XL C/C++ headers)
- Header files mandated by the C and C++ standards (referred to throughout this document as system headers)
- Header files supplied by the operating system (also referred to throughout this document as system headers)
- User-defined header files
You can use any of the following methods to include any type of header file:
- Use the standard
#include <file_name>preprocessor directive in the including source file. - Use the standard
#include "file_name"preprocessor directive in the including source file. - Use the -include compiler option.
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 -stdinc compiler option 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. When searching a header file, the compiler searches the file in all the qualified paths
in order and stops searching when it finds the first one.
- Header files included with -include only: The compiler searches the current (working) directory from which the compiler is invoked.
- Header files included with -include or
#include "file_name": The compiler searches the directory in which the source file is located.1 - All header files: The compiler searches each directory specified by the -I compiler option, in the order that it displays on the command line.
- All header files: The compiler searches the standard directory for the
Open XL C headers
IBM Open XL C/C++ headers
. The default directory for these headers is normally /opt/IBM/openxlC/17.1.4/include. But the search path can be changed with -isystem compiler option. - All header files: The compiler searches the standard directory for the system headers. The default directory for these headers is normally /usr/include/. But the search path can be changed with -isystem.
Note:
- If the -nostdinc or -nostdinc++ compiler option is in effect, steps 4 and 5 are omitted.