2.11 Compiler search rules and the current place

By default, the compiler uses Berkeley UNIX search rules, so source files and #include header files are searched for relative to the current place. The current place is the directory containing the source or header file currently being processed by the compiler.

When a file is found relative to an element of the search path, the directory containing that file becomes the new current place. When the compiler has finished processing that file, it restores the previous current place. At each instant there is a stack of current places corresponding to the stack of nested #include directives. For example, if the current place is the include directory ...\include, and the compiler is seeking the include file sys\defs.h, it locates ...\include\sys\defs.h if it exists. When the compiler begins to process defs.h, the current place becomes ...\include\sys. Any file included by defs.h that is not specified with an absolute path name, is searched for relative to ...\include\sys.
The original current place ...\include is restored only when the compiler has finished processing defs.h.
You can disable the stacking of current places by using the compiler option --kandr_include. This option makes the compiler use Kernighan and Ritchie search rules whereby each nonrooted user #include is searched for relative to the directory containing the source file that is being compiled.
Related concepts
2.12 The ARMCC5INC environment variable
2.9 Factors influencing how the compiler searches for header files
Related reference
2.10 Compiler command-line options and search paths
7.80 -Idir[,dir,...]
7.91 -Jdir[,dir,...]
7.92 --kandr_include
7.159 --sys_include
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.