1*0bfacb9bSmrg@c Copyright (C) 1999-2020 Free Software Foundation, Inc. 2ac8e35e1Smrg@c This is part of the CPP and GCC manuals. 3ac8e35e1Smrg@c For copying conditions, see the file gcc.texi. 4ac8e35e1Smrg 5ac8e35e1Smrg@c --------------------------------------------------------------------- 6ac8e35e1Smrg@c Options affecting include directory search in the preprocessor 7ac8e35e1Smrg@c --------------------------------------------------------------------- 8ac8e35e1Smrg 9ac8e35e1Smrg@c If this file is included with the flag ``cppmanual'' set, it is 10ac8e35e1Smrg@c formatted for inclusion in the CPP manual; otherwise the main GCC manual. 11ac8e35e1Smrg 12ac8e35e1Smrg@item -I @var{dir} 13ac8e35e1Smrg@itemx -iquote @var{dir} 14ac8e35e1Smrg@itemx -isystem @var{dir} 15ac8e35e1Smrg@itemx -idirafter @var{dir} 16ac8e35e1Smrg@opindex I 17ac8e35e1Smrg@opindex iquote 18ac8e35e1Smrg@opindex isystem 19ac8e35e1Smrg@opindex idirafter 20ac8e35e1SmrgAdd the directory @var{dir} to the list of directories to be searched 21ac8e35e1Smrgfor header files during preprocessing. 22ac8e35e1Smrg@ifset cppmanual 23ac8e35e1Smrg@xref{Search Path}. 24ac8e35e1Smrg@end ifset 258dd4bdcdSmrgIf @var{dir} begins with @samp{=} or @code{$SYSROOT}, then the @samp{=} 268dd4bdcdSmrgor @code{$SYSROOT} is replaced by the sysroot prefix; see 278dd4bdcdSmrg@option{--sysroot} and @option{-isysroot}. 28ac8e35e1Smrg 29ac8e35e1SmrgDirectories specified with @option{-iquote} apply only to the quote 30ac8e35e1Smrgform of the directive, @code{@w{#include "@var{file}"}}. 31ac8e35e1SmrgDirectories specified with @option{-I}, @option{-isystem}, 32ac8e35e1Smrgor @option{-idirafter} apply to lookup for both the 33ac8e35e1Smrg@code{@w{#include "@var{file}"}} and 34ac8e35e1Smrg@code{@w{#include <@var{file}>}} directives. 35ac8e35e1Smrg 36ac8e35e1SmrgYou can specify any number or combination of these options on the 37ac8e35e1Smrgcommand line to search for header files in several directories. 38ac8e35e1SmrgThe lookup order is as follows: 39ac8e35e1Smrg 40ac8e35e1Smrg@enumerate 41ac8e35e1Smrg@item 42ac8e35e1SmrgFor the quote form of the include directive, the directory of the current 43ac8e35e1Smrgfile is searched first. 44ac8e35e1Smrg 45ac8e35e1Smrg@item 46ac8e35e1SmrgFor the quote form of the include directive, the directories specified 47ac8e35e1Smrgby @option{-iquote} options are searched in left-to-right order, 48ac8e35e1Smrgas they appear on the command line. 49ac8e35e1Smrg 50ac8e35e1Smrg@item 51ac8e35e1SmrgDirectories specified with @option{-I} options are scanned in 52ac8e35e1Smrgleft-to-right order. 53ac8e35e1Smrg 54ac8e35e1Smrg@item 55ac8e35e1SmrgDirectories specified with @option{-isystem} options are scanned in 56ac8e35e1Smrgleft-to-right order. 57ac8e35e1Smrg 58ac8e35e1Smrg@item 59ac8e35e1SmrgStandard system directories are scanned. 60ac8e35e1Smrg 61ac8e35e1Smrg@item 62ac8e35e1SmrgDirectories specified with @option{-idirafter} options are scanned in 63ac8e35e1Smrgleft-to-right order. 64ac8e35e1Smrg@end enumerate 65ac8e35e1Smrg 66ac8e35e1SmrgYou can use @option{-I} to override a system header 67ac8e35e1Smrgfile, substituting your own version, since these directories are 68ac8e35e1Smrgsearched before the standard system header file directories. 69ac8e35e1SmrgHowever, you should 70ac8e35e1Smrgnot use this option to add directories that contain vendor-supplied 71ac8e35e1Smrgsystem header files; use @option{-isystem} for that. 72ac8e35e1Smrg 73ac8e35e1SmrgThe @option{-isystem} and @option{-idirafter} options also mark the directory 74ac8e35e1Smrgas a system directory, so that it gets the same special treatment that 75ac8e35e1Smrgis applied to the standard system directories. 76ac8e35e1Smrg@ifset cppmanual 77ac8e35e1Smrg@xref{System Headers}. 78ac8e35e1Smrg@end ifset 79ac8e35e1Smrg 80ac8e35e1SmrgIf a standard system include directory, or a directory specified with 81ac8e35e1Smrg@option{-isystem}, is also specified with @option{-I}, the @option{-I} 82ac8e35e1Smrgoption is ignored. The directory is still searched but as a 83ac8e35e1Smrgsystem directory at its normal position in the system include chain. 84ac8e35e1SmrgThis is to ensure that GCC's procedure to fix buggy system headers and 85ac8e35e1Smrgthe ordering for the @code{#include_next} directive are not inadvertently 86ac8e35e1Smrgchanged. 87ac8e35e1SmrgIf you really need to change the search order for system directories, 88ac8e35e1Smrguse the @option{-nostdinc} and/or @option{-isystem} options. 89ac8e35e1Smrg@ifset cppmanual 90ac8e35e1Smrg@xref{System Headers}. 91ac8e35e1Smrg@end ifset 92ac8e35e1Smrg 93ac8e35e1Smrg@item -I- 94ac8e35e1Smrg@opindex I- 95ac8e35e1SmrgSplit the include path. 96ac8e35e1SmrgThis option has been deprecated. Please use @option{-iquote} instead for 97ac8e35e1Smrg@option{-I} directories before the @option{-I-} and remove the @option{-I-} 98ac8e35e1Smrgoption. 99ac8e35e1Smrg 100ac8e35e1SmrgAny directories specified with @option{-I} 101ac8e35e1Smrgoptions before @option{-I-} are searched only for headers requested with 102ac8e35e1Smrg@code{@w{#include "@var{file}"}}; they are not searched for 103ac8e35e1Smrg@code{@w{#include <@var{file}>}}. If additional directories are 104ac8e35e1Smrgspecified with @option{-I} options after the @option{-I-}, those 105ac8e35e1Smrgdirectories are searched for all @samp{#include} directives. 106ac8e35e1Smrg 107ac8e35e1SmrgIn addition, @option{-I-} inhibits the use of the directory of the current 108ac8e35e1Smrgfile directory as the first search directory for @code{@w{#include 109ac8e35e1Smrg"@var{file}"}}. There is no way to override this effect of @option{-I-}. 110ac8e35e1Smrg@ifset cppmanual 111ac8e35e1Smrg@xref{Search Path}. 112ac8e35e1Smrg@end ifset 113ac8e35e1Smrg 114ac8e35e1Smrg@item -iprefix @var{prefix} 115ac8e35e1Smrg@opindex iprefix 116ac8e35e1SmrgSpecify @var{prefix} as the prefix for subsequent @option{-iwithprefix} 117ac8e35e1Smrgoptions. If the prefix represents a directory, you should include the 118ac8e35e1Smrgfinal @samp{/}. 119ac8e35e1Smrg 120ac8e35e1Smrg@item -iwithprefix @var{dir} 121ac8e35e1Smrg@itemx -iwithprefixbefore @var{dir} 122ac8e35e1Smrg@opindex iwithprefix 123ac8e35e1Smrg@opindex iwithprefixbefore 124ac8e35e1SmrgAppend @var{dir} to the prefix specified previously with 125ac8e35e1Smrg@option{-iprefix}, and add the resulting directory to the include search 126ac8e35e1Smrgpath. @option{-iwithprefixbefore} puts it in the same place @option{-I} 127ac8e35e1Smrgwould; @option{-iwithprefix} puts it where @option{-idirafter} would. 128ac8e35e1Smrg 129ac8e35e1Smrg@item -isysroot @var{dir} 130ac8e35e1Smrg@opindex isysroot 131ac8e35e1SmrgThis option is like the @option{--sysroot} option, but applies only to 132ac8e35e1Smrgheader files (except for Darwin targets, where it applies to both header 133ac8e35e1Smrgfiles and libraries). See the @option{--sysroot} option for more 134ac8e35e1Smrginformation. 135ac8e35e1Smrg 136ac8e35e1Smrg@item -imultilib @var{dir} 137ac8e35e1Smrg@opindex imultilib 138ac8e35e1SmrgUse @var{dir} as a subdirectory of the directory containing 139ac8e35e1Smrgtarget-specific C++ headers. 140ac8e35e1Smrg 141ac8e35e1Smrg@item -nostdinc 142ac8e35e1Smrg@opindex nostdinc 143ac8e35e1SmrgDo not search the standard system directories for header files. 144ac8e35e1SmrgOnly the directories explicitly specified with @option{-I}, 145ac8e35e1Smrg@option{-iquote}, @option{-isystem}, and/or @option{-idirafter} 146ac8e35e1Smrgoptions (and the directory of the current file, if appropriate) 147ac8e35e1Smrgare searched. 148ac8e35e1Smrg 149ac8e35e1Smrg@item -nostdinc++ 150ac8e35e1Smrg@opindex nostdinc++ 151ac8e35e1SmrgDo not search for header files in the C++-specific standard directories, 152ac8e35e1Smrgbut do still search the other standard directories. (This option is 153ac8e35e1Smrgused when building the C++ library.) 154ac8e35e1Smrg 155