• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/cpp/
1<html lang="en">
2<head>
3<title>Search Path - The C Preprocessor</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="The C Preprocessor">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Header-Files.html#Header-Files" title="Header Files">
9<link rel="prev" href="Include-Operation.html#Include-Operation" title="Include Operation">
10<link rel="next" href="Once_002dOnly-Headers.html#Once_002dOnly-Headers" title="Once-Only Headers">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
141997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
152008, 2009, 2010, 2011
16Free Software Foundation, Inc.
17
18Permission is granted to copy, distribute and/or modify this document
19under the terms of the GNU Free Documentation License, Version 1.3 or
20any later version published by the Free Software Foundation.  A copy of
21the license is included in the
22section entitled ``GNU Free Documentation License''.
23
24This manual contains no Invariant Sections.  The Front-Cover Texts are
25(a) (see below), and the Back-Cover Texts are (b) (see below).
26
27(a) The FSF's Front-Cover Text is:
28
29     A GNU Manual
30
31(b) The FSF's Back-Cover Text is:
32
33     You have freedom to copy and modify this GNU Manual, like GNU
34     software.  Copies published by the Free Software Foundation raise
35     funds for GNU development.
36-->
37<meta http-equiv="Content-Style-Type" content="text/css">
38<style type="text/css"><!--
39  pre.display { font-family:inherit }
40  pre.format  { font-family:inherit }
41  pre.smalldisplay { font-family:inherit; font-size:smaller }
42  pre.smallformat  { font-family:inherit; font-size:smaller }
43  pre.smallexample { font-size:smaller }
44  pre.smalllisp    { font-size:smaller }
45  span.sc    { font-variant:small-caps }
46  span.roman { font-family:serif; font-weight:normal; } 
47  span.sansserif { font-family:sans-serif; font-weight:normal; } 
48--></style>
49<link rel="stylesheet" type="text/css" href="../cs.css">
50</head>
51<body>
52<div class="node">
53<a name="Search-Path"></a>
54<p>
55Next:&nbsp;<a rel="next" accesskey="n" href="Once_002dOnly-Headers.html#Once_002dOnly-Headers">Once-Only Headers</a>,
56Previous:&nbsp;<a rel="previous" accesskey="p" href="Include-Operation.html#Include-Operation">Include Operation</a>,
57Up:&nbsp;<a rel="up" accesskey="u" href="Header-Files.html#Header-Files">Header Files</a>
58<hr>
59</div>
60
61<h3 class="section">2.3 Search Path</h3>
62
63<p>GCC looks in several different places for headers.  On a normal Unix
64system, if you do not instruct it otherwise, it will look for headers
65requested with <code>#include&nbsp;&lt;</code><var>file</var><code>&gt;<!-- /@w --></code> in:
66
67<pre class="smallexample">     /usr/local/include
68     <var>libdir</var>/gcc/<var>target</var>/<var>version</var>/include
69     /usr/<var>target</var>/include
70     /usr/include
71</pre>
72   <p>For C++ programs, it will also look in <samp><span class="file">/usr/include/g++-v3</span></samp>,
73first.  In the above, <var>target</var> is the canonical name of the system
74GCC was configured to compile code for; often but not always the same as
75the canonical name of the system it runs on.  <var>version</var> is the
76version of GCC in use.
77
78   <p>You can add to this list with the <samp><span class="option">-I</span><var>dir</var></samp> command line
79option.  All the directories named by <samp><span class="option">-I</span></samp> are searched, in
80left-to-right order, <em>before</em> the default directories.  The only
81exception is when <samp><span class="file">dir</span></samp> is already searched by default.  In
82this case, the option is ignored and the search order for system
83directories remains unchanged.
84
85   <p>Duplicate directories are removed from the quote and bracket search
86chains before the two chains are merged to make the final search chain. 
87Thus, it is possible for a directory to occur twice in the final search
88chain if it was specified in both the quote and bracket chains.
89
90   <p>You can prevent GCC from searching any of the default directories with
91the <samp><span class="option">-nostdinc</span></samp> option.  This is useful when you are compiling an
92operating system kernel or some other program that does not use the
93standard C library facilities, or the standard C library itself. 
94<samp><span class="option">-I</span></samp> options are not ignored as described above when
95<samp><span class="option">-nostdinc</span></samp> is in effect.
96
97   <p>GCC looks for headers requested with <code>#include&nbsp;"</code><var>file</var><code>"<!-- /@w --></code>
98first in the directory containing the current file, then in the
99directories as specified by <samp><span class="option">-iquote</span></samp> options, then in the same
100places it would have looked for a header requested with angle
101brackets.  For example, if <samp><span class="file">/usr/include/sys/stat.h</span></samp> contains
102<code>#include&nbsp;"types.h"<!-- /@w --></code>, GCC looks for <samp><span class="file">types.h</span></samp> first in
103<samp><span class="file">/usr/include/sys</span></samp>, then in its usual search path.
104
105   <p>&lsquo;<samp><span class="samp">#line</span></samp>&rsquo; (see <a href="Line-Control.html#Line-Control">Line Control</a>) does not change GCC's idea of the
106directory containing the current file.
107
108   <p>You may put <samp><span class="option">-I-</span></samp> at any point in your list of <samp><span class="option">-I</span></samp> options. 
109This has two effects.  First, directories appearing before the
110<samp><span class="option">-I-</span></samp> in the list are searched only for headers requested with
111quote marks.  Directories after <samp><span class="option">-I-</span></samp> are searched for all
112headers.  Second, the directory containing the current file is not
113searched for anything, unless it happens to be one of the directories
114named by an <samp><span class="option">-I</span></samp> switch.  <samp><span class="option">-I-</span></samp> is deprecated, <samp><span class="option">-iquote</span></samp>
115should be used instead.
116
117   <p><samp><span class="option">-I. -I-</span></samp> is not the same as no <samp><span class="option">-I</span></samp> options at all, and does
118not cause the same behavior for &lsquo;<samp><span class="samp">&lt;&gt;</span></samp>&rsquo; includes that &lsquo;<samp><span class="samp">""</span></samp>&rsquo;
119includes get with no special options.  <samp><span class="option">-I.</span></samp> searches the
120compiler's current working directory for header files.  That may or may
121not be the same as the directory containing the current file.
122
123   <p>If you need to look for headers in a directory named <samp><span class="file">-</span></samp>, write
124<samp><span class="option">-I./-</span></samp>.
125
126   <p>There are several more ways to adjust the header search path.  They are
127generally less useful.  See <a href="Invocation.html#Invocation">Invocation</a>.
128
129   </body></html>
130
131