cpp: Search Path

1 
1 2.3 Search Path
1 ===============
1 
1 By default, the preprocessor looks for header files included by the
1 quote form of the directive '#include "FILE"' first relative to the
1 directory of the current file, and then in a preconfigured list of
1 standard system directories.  For example, if '/usr/include/sys/stat.h'
1 contains '#include "types.h"', GCC looks for 'types.h' first in
1 '/usr/include/sys', then in its usual search path.
1 
1    For the angle-bracket form '#include <FILE>', the preprocessor's
1 default behavior is to look only in the standard system directories.
1 The exact search directory list depends on the target system, how GCC is
1 configured, and where it is installed.  You can find the default search
1 directory list for your version of CPP by invoking it with the '-v'
1 option.  For example,
1 
1      cpp -v /dev/null -o /dev/null
1 
1    There are a number of command-line options you can use to add
1 additional directories to the search path.  The most commonly-used
1 option is '-IDIR', which causes DIR to be searched after the current
1 directory (for the quote form of the directive) and ahead of the
1 standard system directories.  You can specify multiple '-I' options on
1 the command line, in which case the directories are searched in
1 left-to-right order.
1 
1    If you need separate control over the search paths for the quote and
1 angle-bracket forms of the '#include' directive, you can use the
11 '-iquote' and/or '-isystem' options instead of '-I'.  ⇒
 Invocation, for a detailed description of these options, as well as
1 others that are less generally useful.
1 
1    If you specify other options on the command line, such as '-I', that
1 affect where the preprocessor searches for header files, the directory
1 list printed by the '-v' option reflects the actual search path used by
1 the preprocessor.
1 
1    Note that you can also prevent the preprocessor from searching any of
1 the default system header directories with the '-nostdinc' option.  This
1 is useful when you are compiling an operating system kernel or some
1 other program that does not use the standard C library facilities, or
1 the standard C library itself.
1