Include file search procedure
This is a detailed description of the compiler’s #include file search procedure:
The string found between the
""and<>in the#includedirective is used verbatim as a source file name.If the name of the
#includefile is an absolute path specified in angle brackets or double quotes, that file is opened.If the compiler encounters the name of an
#includefile in angle brackets, such as:#include <stdio.h>
it searches these directories for the file to include:
The directories specified with the
-Ioption, in the order that they were specified, see -I.The directories specified using the
C_INCLUDEenvironment variable, if any, see Environment variables.The automatically set up library system include directories. See ‑‑dlib_config.
If the compiler encounters the name of an
#includefile in double quotes, for example:#include "vars.h"
it searches the directory of the source file in which the
#includestatement occurs, and then performs the same sequence as for angle-bracketed filenames.
If there are nested #include files, the compiler starts searching the directory of the file that was last included, iterating upwards for each included file, searching the source file directory last. For example:
src.c in directory dir\src #include "src.h" ... src.h in directory dir\include #include "config.h" ...
When dir\exe is the current directory, use this command for compilation:
iccrh850 ..\src\src.c -I..\include -I..\debugconfigThen the following directories are searched in the order listed below for the file config.h, which in this example is located in the dir\debugconfig directory:
| Current file is |
| File including current file ( |
| As specified with the first |
| As specified with the second |
Use angle brackets for standard header files, like stdio.h, and double quotes for files that are part of your application.
Note
Both \ and / can be used as directory delimiters.
For more information, see Overview of the preprocessor.