GNU Info

Info Node: (cpp-300.info)Search Path

(cpp-300.info)Search Path


Next: Once-Only Headers Prev: Include Operation Up: Header Files
Enter node , (file) or (file)node

Search Path
===========

   GCC looks in several different places for headers.  On a normal Unix
system, if you do not instruct it otherwise, it will look for headers
requested with `#include <FILE>' in:

     /usr/local/include
     /usr/lib/gcc-lib/TARGET/VERSION/include
     /usr/TARGET/include
     /usr/include

   For C++ programs, it will also look in `/usr/include/g++-v3', first.
In the above, TARGET is the canonical name of the system GCC was
configured to compile code for; often but not always the same as the
canonical name of the system it runs on.  VERSION is the version of GCC
in use.

   You can add to this list with the `-IDIR' command line option.  All
the directories named by `-I' are searched, in left-to-right order,
_before_ the default directories.  You can also prevent GCC from
searching any of the default directories with the `-nostdinc' option.
This is useful when you are compiling an operating system kernel or
some other program that does not use the standard C library facilities,
or the standard C library itself.

   GCC looks for headers requested with `#include "FILE"' first in the
directory containing the current file, then in the same places it would
have looked for a header requested with angle brackets.  For example,
if `/usr/include/sys/stat.h' contains `#include "types.h"', GCC looks
for `types.h' first in `/usr/include/sys', then in its usual search
path.

   `#line' (Note: Line Control) does not change GCC's idea of the
directory containing the current file.

   You may put `-I-' at any point in your list of `-I' options.  This
has two effects.  First, directories appearing before the `-I-' in the
list are searched only for headers requested with quote marks.
Directories after `-I-' are searched for all headers.  Second, the
directory containing the current file is not searched for anything,
unless it happens to be one of the directories named by an `-I' switch.

   `-I. -I-' is not the same as no `-I' options at all, and does not
cause the same behavior for `<>' includes that `""' includes get with
no special options.  `-I.' searches the compiler's current working
directory for header files.  That may or may not be the same as the
directory containing the current file.

   If you need to look for headers in a directory named `-', write
`-I./-'.

   There are several more ways to adjust the header search path.  They
are generally less useful.  Note: Invocation.


automatically generated by info2www version 1.2.2.9