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