xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/doc/cppdiropts.texi (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1*4c3eb207Smrg@c Copyright (C) 1999-2020 Free Software Foundation, Inc.
23ad841b2Smrg@c This is part of the CPP and GCC manuals.
33ad841b2Smrg@c For copying conditions, see the file gcc.texi.
43ad841b2Smrg
53ad841b2Smrg@c ---------------------------------------------------------------------
63ad841b2Smrg@c Options affecting include directory search in the preprocessor
73ad841b2Smrg@c ---------------------------------------------------------------------
83ad841b2Smrg
93ad841b2Smrg@c If this file is included with the flag ``cppmanual'' set, it is
103ad841b2Smrg@c formatted for inclusion in the CPP manual; otherwise the main GCC manual.
113ad841b2Smrg
123ad841b2Smrg@item -I @var{dir}
133ad841b2Smrg@itemx -iquote @var{dir}
143ad841b2Smrg@itemx -isystem @var{dir}
153ad841b2Smrg@itemx -idirafter @var{dir}
163ad841b2Smrg@opindex I
173ad841b2Smrg@opindex iquote
183ad841b2Smrg@opindex isystem
193ad841b2Smrg@opindex idirafter
203ad841b2SmrgAdd the directory @var{dir} to the list of directories to be searched
213ad841b2Smrgfor header files during preprocessing.
223ad841b2Smrg@ifset cppmanual
233ad841b2Smrg@xref{Search Path}.
243ad841b2Smrg@end ifset
25cef8759bSmrgIf @var{dir} begins with @samp{=} or @code{$SYSROOT}, then the @samp{=}
26cef8759bSmrgor @code{$SYSROOT} is replaced by the sysroot prefix; see
27cef8759bSmrg@option{--sysroot} and @option{-isysroot}.
283ad841b2Smrg
293ad841b2SmrgDirectories specified with @option{-iquote} apply only to the quote
303ad841b2Smrgform of the directive, @code{@w{#include "@var{file}"}}.
313ad841b2SmrgDirectories specified with @option{-I}, @option{-isystem},
323ad841b2Smrgor @option{-idirafter} apply to lookup for both the
333ad841b2Smrg@code{@w{#include "@var{file}"}} and
343ad841b2Smrg@code{@w{#include <@var{file}>}} directives.
353ad841b2Smrg
363ad841b2SmrgYou can specify any number or combination of these options on the
373ad841b2Smrgcommand line to search for header files in several directories.
383ad841b2SmrgThe lookup order is as follows:
393ad841b2Smrg
403ad841b2Smrg@enumerate
413ad841b2Smrg@item
423ad841b2SmrgFor the quote form of the include directive, the directory of the current
433ad841b2Smrgfile is searched first.
443ad841b2Smrg
453ad841b2Smrg@item
463ad841b2SmrgFor the quote form of the include directive, the directories specified
473ad841b2Smrgby @option{-iquote} options are searched in left-to-right order,
483ad841b2Smrgas they appear on the command line.
493ad841b2Smrg
503ad841b2Smrg@item
513ad841b2SmrgDirectories specified with @option{-I} options are scanned in
523ad841b2Smrgleft-to-right order.
533ad841b2Smrg
543ad841b2Smrg@item
553ad841b2SmrgDirectories specified with @option{-isystem} options are scanned in
563ad841b2Smrgleft-to-right order.
573ad841b2Smrg
583ad841b2Smrg@item
593ad841b2SmrgStandard system directories are scanned.
603ad841b2Smrg
613ad841b2Smrg@item
623ad841b2SmrgDirectories specified with @option{-idirafter} options are scanned in
633ad841b2Smrgleft-to-right order.
643ad841b2Smrg@end enumerate
653ad841b2Smrg
663ad841b2SmrgYou can use @option{-I} to override a system header
673ad841b2Smrgfile, substituting your own version, since these directories are
683ad841b2Smrgsearched before the standard system header file directories.
693ad841b2SmrgHowever, you should
703ad841b2Smrgnot use this option to add directories that contain vendor-supplied
713ad841b2Smrgsystem header files; use @option{-isystem} for that.
723ad841b2Smrg
733ad841b2SmrgThe @option{-isystem} and @option{-idirafter} options also mark the directory
743ad841b2Smrgas a system directory, so that it gets the same special treatment that
753ad841b2Smrgis applied to the standard system directories.
763ad841b2Smrg@ifset cppmanual
773ad841b2Smrg@xref{System Headers}.
783ad841b2Smrg@end ifset
793ad841b2Smrg
803ad841b2SmrgIf a standard system include directory, or a directory specified with
813ad841b2Smrg@option{-isystem}, is also specified with @option{-I}, the @option{-I}
823ad841b2Smrgoption is ignored.  The directory is still searched but as a
833ad841b2Smrgsystem directory at its normal position in the system include chain.
843ad841b2SmrgThis is to ensure that GCC's procedure to fix buggy system headers and
853ad841b2Smrgthe ordering for the @code{#include_next} directive are not inadvertently
863ad841b2Smrgchanged.
873ad841b2SmrgIf you really need to change the search order for system directories,
883ad841b2Smrguse the @option{-nostdinc} and/or @option{-isystem} options.
893ad841b2Smrg@ifset cppmanual
903ad841b2Smrg@xref{System Headers}.
913ad841b2Smrg@end ifset
923ad841b2Smrg
933ad841b2Smrg@item -I-
943ad841b2Smrg@opindex I-
953ad841b2SmrgSplit the include path.
963ad841b2SmrgThis option has been deprecated.  Please use @option{-iquote} instead for
973ad841b2Smrg@option{-I} directories before the @option{-I-} and remove the @option{-I-}
983ad841b2Smrgoption.
993ad841b2Smrg
1003ad841b2SmrgAny directories specified with @option{-I}
1013ad841b2Smrgoptions before @option{-I-} are searched only for headers requested with
1023ad841b2Smrg@code{@w{#include "@var{file}"}}; they are not searched for
1033ad841b2Smrg@code{@w{#include <@var{file}>}}.  If additional directories are
1043ad841b2Smrgspecified with @option{-I} options after the @option{-I-}, those
1053ad841b2Smrgdirectories are searched for all @samp{#include} directives.
1063ad841b2Smrg
1073ad841b2SmrgIn addition, @option{-I-} inhibits the use of the directory of the current
1083ad841b2Smrgfile directory as the first search directory for @code{@w{#include
1093ad841b2Smrg"@var{file}"}}.  There is no way to override this effect of @option{-I-}.
1103ad841b2Smrg@ifset cppmanual
1113ad841b2Smrg@xref{Search Path}.
1123ad841b2Smrg@end ifset
1133ad841b2Smrg
1143ad841b2Smrg@item -iprefix @var{prefix}
1153ad841b2Smrg@opindex iprefix
1163ad841b2SmrgSpecify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
1173ad841b2Smrgoptions.  If the prefix represents a directory, you should include the
1183ad841b2Smrgfinal @samp{/}.
1193ad841b2Smrg
1203ad841b2Smrg@item -iwithprefix @var{dir}
1213ad841b2Smrg@itemx -iwithprefixbefore @var{dir}
1223ad841b2Smrg@opindex iwithprefix
1233ad841b2Smrg@opindex iwithprefixbefore
1243ad841b2SmrgAppend @var{dir} to the prefix specified previously with
1253ad841b2Smrg@option{-iprefix}, and add the resulting directory to the include search
1263ad841b2Smrgpath.  @option{-iwithprefixbefore} puts it in the same place @option{-I}
1273ad841b2Smrgwould; @option{-iwithprefix} puts it where @option{-idirafter} would.
1283ad841b2Smrg
1293ad841b2Smrg@item -isysroot @var{dir}
1303ad841b2Smrg@opindex isysroot
1313ad841b2SmrgThis option is like the @option{--sysroot} option, but applies only to
1323ad841b2Smrgheader files (except for Darwin targets, where it applies to both header
1333ad841b2Smrgfiles and libraries).  See the @option{--sysroot} option for more
1343ad841b2Smrginformation.
1353ad841b2Smrg
1363ad841b2Smrg@item -imultilib @var{dir}
1373ad841b2Smrg@opindex imultilib
1383ad841b2SmrgUse @var{dir} as a subdirectory of the directory containing
1393ad841b2Smrgtarget-specific C++ headers.
1403ad841b2Smrg
1413ad841b2Smrg@item -nostdinc
1423ad841b2Smrg@opindex nostdinc
1433ad841b2SmrgDo not search the standard system directories for header files.
1443ad841b2SmrgOnly the directories explicitly specified with @option{-I},
1453ad841b2Smrg@option{-iquote}, @option{-isystem}, and/or @option{-idirafter}
1463ad841b2Smrgoptions (and the directory of the current file, if appropriate)
1473ad841b2Smrgare searched.
1483ad841b2Smrg
1493ad841b2Smrg@item -nostdinc++
1503ad841b2Smrg@opindex nostdinc++
1513ad841b2SmrgDo not search for header files in the C++-specific standard directories,
1523ad841b2Smrgbut do still search the other standard directories.  (This option is
1533ad841b2Smrgused when building the C++ library.)
1543ad841b2Smrg
155