source: public/doc/gnu-c/Search-Path.html@ 02598c2

Last change on this file since 02598c2 was 02598c2, checked in by Mikhail Kirillov <w96k@…>, on Oct 6, 2022 at 12:36:29 PM

Add gnu-c

  • Property mode set to 100644
File size: 6.3 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 2022 Richard Stallman and Free Software Foundation, Inc.
4
5(The work of Trevis Rothwell and Nelson Beebe has been assigned or
6licensed to the FSF.)
7
8Permission is granted to copy, distribute and/or modify this document
9under the terms of the GNU Free Documentation License, Version 1.3 or
10any later version published by the Free Software Foundation; with the
11Invariant Sections being "GNU General Public License," with the
12Front-Cover Texts being "A GNU Manual," and with the Back-Cover
13Texts as in (a) below. A copy of the license is included in the
14section entitled "GNU Free Documentation License."
15
16(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
17modify this GNU manual. Buying copies from the FSF supports it in
18developing GNU and promoting software freedom." -->
19<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
20<head>
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<title>Search Path (GNU C Language Manual)</title>
23
24<meta name="description" content="Search Path (GNU C Language Manual)">
25<meta name="keywords" content="Search Path (GNU C Language Manual)">
26<meta name="resource-type" content="document">
27<meta name="distribution" content="global">
28<meta name="Generator" content="makeinfo">
29<link href="index.html" rel="start" title="Top">
30<link href="Symbol-Index.html" rel="index" title="Symbol Index">
31<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
32<link href="Header-Files.html" rel="up" title="Header Files">
33<link href="Once_002dOnly-Headers.html" rel="next" title="Once-Only Headers">
34<link href="include-Operation.html" rel="prev" title="include Operation">
35<style type="text/css">
36<!--
37a.summary-letter {text-decoration: none}
38blockquote.indentedblock {margin-right: 0em}
39div.display {margin-left: 3.2em}
40div.example {margin-left: 3.2em}
41div.lisp {margin-left: 3.2em}
42kbd {font-style: oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47span.nolinebreak {white-space: nowrap}
48span.roman {font-family: initial; font-weight: normal}
49span.sansserif {font-family: sans-serif; font-weight: normal}
50ul.no-bullet {list-style: none}
51-->
52</style>
53
54
55</head>
56
57<body lang="en">
58<span id="Search-Path"></span><div class="header">
59<p>
60Next: <a href="Once_002dOnly-Headers.html" accesskey="n" rel="next">Once-Only Headers</a>, Previous: <a href="include-Operation.html" accesskey="p" rel="prev">include Operation</a>, Up: <a href="Header-Files.html" accesskey="u" rel="up">Header Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
61</div>
62<hr>
63<span id="Search-Path-1"></span><h4 class="subsection">26.4.3 Search Path</h4>
64
65<p>GCC looks in several different places for header files to be included.
66On the GNU system, and Unix systems, the default directories for
67system header files are:
68</p>
69<div class="example">
70<pre class="example"><var>libdir</var>/gcc/<var>target</var>/<var>version</var>/include
71/usr/local/include
72<var>libdir</var>/gcc/<var>target</var>/<var>version</var>/include-fixed
73<var>libdir</var>/<var>target</var>/include
74/usr/include/<var>target</var>
75/usr/include
76</pre></div>
77
78<p>The list may be different in some operating systems. Other
79directories are added for C++.
80</p>
81<p>In the above, <var>target</var> is the canonical name of the system GCC was
82configured to compile code for; often but not always the same as the
83canonical name of the system it runs on. <var>version</var> is the version
84of GCC in use.
85</p>
86<p>You can add to this list with the <samp>-I<var>dir</var></samp> command-line
87option. All the directories named by <samp>-I</samp> are searched, in
88left-to-right order, <em>before</em> the default directories. The only
89exception is when <samp>dir</samp> is already searched by default. In
90this case, the option is ignored and the search order for system
91directories remains unchanged.
92</p>
93<p>Duplicate directories are removed from the quote and bracket search
94chains before the two chains are merged to make the final search chain.
95Thus, it is possible for a directory to occur twice in the final search
96chain if it was specified in both the quote and bracket chains.
97</p>
98<p>You can prevent GCC from searching any of the default directories with
99the <samp>-nostdinc</samp> option. This is useful when you are compiling an
100operating system kernel or some other program that does not use the
101standard C library facilities, or the standard C library itself.
102<samp>-I</samp> options are not ignored as described above when
103<samp>-nostdinc</samp> is in effect.
104</p>
105<p>GCC looks for headers requested with <code>#include&nbsp;&quot;<var>file</var>&quot;<!-- /@w --></code>
106first in the directory containing the current file, then in the
107<em>quote directories</em> specified by <samp>-iquote</samp> options, then in
108the same places it looks for a system header. For example, if
109<samp>/usr/include/sys/stat.h</samp> contains <code>#include&nbsp;&quot;types.h&quot;<!-- /@w --></code>,
110GCC looks for <samp>types.h</samp> first in <samp>/usr/include/sys</samp>, then in
111the quote directories and then in its usual search path.
112</p>
113<p><code>#line</code> (see <a href="Line-Control.html">Line Control</a>) does not change GCC&rsquo;s idea of the
114directory containing the current file.
115</p>
116<span id="index-quote-directories"></span>
117<p>The <samp>-I-</samp> is an old-fashioned, deprecated way to specify the
118quote directories. To look for headers in a directory named <samp>-</samp>,
119specify <samp>-I./-</samp>. There are several more ways to adjust the
120header search path. See <a href="https://gcc.gnu.org/onlinedocs/gcc/invocation.html#invocation">Invoking GCC</a> in <cite>Using the GNU Compiler Collection</cite>.
121</p>
122<hr>
123<div class="header">
124<p>
125Next: <a href="Once_002dOnly-Headers.html" accesskey="n" rel="next">Once-Only Headers</a>, Previous: <a href="include-Operation.html" accesskey="p" rel="prev">include Operation</a>, Up: <a href="Header-Files.html" accesskey="u" rel="up">Header Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
126</div>
127
128
129
130</body>
131</html>
Note: See TracBrowser for help on using the repository browser.