]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/cppdiropts.texi
Update copyright years.
[thirdparty/gcc.git] / gcc / doc / cppdiropts.texi
CommitLineData
8d9254fc 1@c Copyright (C) 1999-2020 Free Software Foundation, Inc.
c05169aa
SL
2@c This is part of the CPP and GCC manuals.
3@c For copying conditions, see the file gcc.texi.
4
5@c ---------------------------------------------------------------------
6@c Options affecting include directory search in the preprocessor
7@c ---------------------------------------------------------------------
8
9@c If this file is included with the flag ``cppmanual'' set, it is
10@c formatted for inclusion in the CPP manual; otherwise the main GCC manual.
11
12@item -I @var{dir}
ec85a978
SL
13@itemx -iquote @var{dir}
14@itemx -isystem @var{dir}
15@itemx -idirafter @var{dir}
c05169aa 16@opindex I
ec85a978
SL
17@opindex iquote
18@opindex isystem
19@opindex idirafter
c05169aa 20Add the directory @var{dir} to the list of directories to be searched
ec85a978 21for header files during preprocessing.
c05169aa
SL
22@ifset cppmanual
23@xref{Search Path}.
24@end ifset
a055692a
RO
25If @var{dir} begins with @samp{=} or @code{$SYSROOT}, then the @samp{=}
26or @code{$SYSROOT} is replaced by the sysroot prefix; see
27@option{--sysroot} and @option{-isysroot}.
ec85a978
SL
28
29Directories specified with @option{-iquote} apply only to the quote
30form of the directive, @code{@w{#include "@var{file}"}}.
31Directories specified with @option{-I}, @option{-isystem},
32or @option{-idirafter} apply to lookup for both the
33@code{@w{#include "@var{file}"}} and
34@code{@w{#include <@var{file}>}} directives.
35
36You can specify any number or combination of these options on the
37command line to search for header files in several directories.
38The lookup order is as follows:
39
40@enumerate
41@item
42For the quote form of the include directive, the directory of the current
43file is searched first.
44
45@item
46For the quote form of the include directive, the directories specified
47by @option{-iquote} options are searched in left-to-right order,
48as they appear on the command line.
49
50@item
51Directories specified with @option{-I} options are scanned in
52left-to-right order.
c05169aa 53
ec85a978
SL
54@item
55Directories specified with @option{-isystem} options are scanned in
56left-to-right order.
57
58@item
59Standard system directories are scanned.
60
61@item
62Directories specified with @option{-idirafter} options are scanned in
63left-to-right order.
64@end enumerate
65
66You can use @option{-I} to override a system header
c05169aa 67file, substituting your own version, since these directories are
ec85a978
SL
68searched before the standard system header file directories.
69However, you should
c05169aa 70not use this option to add directories that contain vendor-supplied
ec85a978
SL
71system header files; use @option{-isystem} for that.
72
73The @option{-isystem} and @option{-idirafter} options also mark the directory
74as a system directory, so that it gets the same special treatment that
75is applied to the standard system directories.
76@ifset cppmanual
77@xref{System Headers}.
78@end ifset
c05169aa
SL
79
80If a standard system include directory, or a directory specified with
81@option{-isystem}, is also specified with @option{-I}, the @option{-I}
82option is ignored. The directory is still searched but as a
83system directory at its normal position in the system include chain.
84This is to ensure that GCC's procedure to fix buggy system headers and
ec85a978
SL
85the ordering for the @code{#include_next} directive are not inadvertently
86changed.
c05169aa
SL
87If you really need to change the search order for system directories,
88use the @option{-nostdinc} and/or @option{-isystem} options.
89@ifset cppmanual
90@xref{System Headers}.
91@end ifset
92
c05169aa
SL
93@item -I-
94@opindex I-
95Split the include path.
96This option has been deprecated. Please use @option{-iquote} instead for
97@option{-I} directories before the @option{-I-} and remove the @option{-I-}
98option.
99
100Any directories specified with @option{-I}
101options before @option{-I-} are searched only for headers requested with
102@code{@w{#include "@var{file}"}}; they are not searched for
103@code{@w{#include <@var{file}>}}. If additional directories are
104specified with @option{-I} options after the @option{-I-}, those
105directories are searched for all @samp{#include} directives.
106
107In addition, @option{-I-} inhibits the use of the directory of the current
108file directory as the first search directory for @code{@w{#include
109"@var{file}"}}. There is no way to override this effect of @option{-I-}.
110@ifset cppmanual
111@xref{Search Path}.
112@end ifset
113
c05169aa
SL
114@item -iprefix @var{prefix}
115@opindex iprefix
116Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
117options. If the prefix represents a directory, you should include the
118final @samp{/}.
119
120@item -iwithprefix @var{dir}
121@itemx -iwithprefixbefore @var{dir}
122@opindex iwithprefix
123@opindex iwithprefixbefore
124Append @var{dir} to the prefix specified previously with
125@option{-iprefix}, and add the resulting directory to the include search
126path. @option{-iwithprefixbefore} puts it in the same place @option{-I}
127would; @option{-iwithprefix} puts it where @option{-idirafter} would.
128
129@item -isysroot @var{dir}
130@opindex isysroot
131This option is like the @option{--sysroot} option, but applies only to
132header files (except for Darwin targets, where it applies to both header
133files and libraries). See the @option{--sysroot} option for more
134information.
135
136@item -imultilib @var{dir}
137@opindex imultilib
138Use @var{dir} as a subdirectory of the directory containing
139target-specific C++ headers.
140
141@item -nostdinc
142@opindex nostdinc
143Do not search the standard system directories for header files.
ec85a978
SL
144Only the directories explicitly specified with @option{-I},
145@option{-iquote}, @option{-isystem}, and/or @option{-idirafter}
146options (and the directory of the current file, if appropriate)
147are searched.
c05169aa
SL
148
149@item -nostdinc++
150@opindex nostdinc++
151Do not search for header files in the C++-specific standard directories,
152but do still search the other standard directories. (This option is
153used when building the C++ library.)
154