cpp_opts->traditional = 1;
break;
+ case OPT_fsearch_include_path:
+ cpp_opts->main_search = CMS_user;
+ break;
+
+ case OPT_fsearch_include_path_:
+ if (!strcmp (arg, "user"))
+ cpp_opts->main_search = CMS_user;
+ else if (!strcmp (arg, "system"))
+ cpp_opts->main_search = CMS_system;
+ else
+ error ("invalid argument %qs to %<-fsearch-include-path%>", arg);
+ break;
+
case OPT_v:
verbose = true;
break;
C++ ObjC++ Optimization Var(flag_rtti) Init(1)
Generate run time type descriptor information.
+fsearch-include-path
+C ObjC C++ ObjC++
+Look for the main source file on the include path.
+
+fsearch-include-path=
+C++ ObjC++ Joined RejectNegative Undocumented
+
fshort-enums
C ObjC C++ ObjC++ LTO Optimization Var(flag_short_enums)
Use the narrowest integer type possible for enumeration types.
}
auto *opt = cpp_get_options (reader);
opt->module_directives = true;
- opt->main_search = cpp_main_search (flag_header_unit);
+ if (opt->main_search == CMS_none)
+ opt->main_search = cpp_main_search (flag_header_unit);
}
}
@item -fmax-include-depth=@var{depth}
Set the maximum depth of the nested #include. The default is 200.
+@opindex fsearch-include-path
+@item -fsearch-include-path@r{[}=@var{kind}@r{]}
+Look for input files on the #include path, not just the current
+directory. This is particularly useful with C++20 modules, for which
+both header units and module interface units need to be compiled
+directly:
+
+@smallexample
+g++ -c -std=c++20 -fmodules -fsearch-include-path bits/stdc++.h bits/std.cc
+@end smallexample
+
+@var{kind} defaults to @samp{user}, which looks on the @code{#include
+"@dots{}"} search path; you can also explicitly specify @samp{system}
+for the @code{#include <@dots{}>} search path.
+
@opindex ftabstop
@item -ftabstop=@var{width}
Set the distance between tab stops. This helps the preprocessor report
inhibits output of the object file, as header files have no associated
object file.
+Alternately, or for a module interface unit in an installed location,
+you can use @option{-fsearch-include-path} to specify that the main
+source file should be found on the include path rather than the
+current directory.
+
Header units can be used in much the same way as precompiled headers
(@pxref{Precompiled Headers}), but with fewer restrictions: an
#include that is translated to a header unit import can appear at any
location_t loc, const char *input_charset);
static bool read_file (cpp_reader *pfile, _cpp_file *file,
location_t loc);
-static struct cpp_dir *search_path_head (cpp_reader *, const char *fname,
- int angle_brackets, enum include_type,
- bool suppress_diagnostic = false);
static const char *dir_name_of_file (_cpp_file *file);
static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int,
location_t);
/* Return the directory from which searching for FNAME should start,
considering the directive TYPE and ANGLE_BRACKETS. If there is
nothing left in the path, returns NULL. */
-static struct cpp_dir *
+struct cpp_dir *
search_path_head (cpp_reader *pfile, const char *fname, int angle_brackets,
enum include_type type, bool suppress_diagnostic)
{
/* Set the default target (if there is none already). */
deps_add_default_target (deps, fname);
+ auto main_search = CPP_OPTION (pfile, main_search);
+ bool angle = main_search == CMS_system;
+ cpp_dir *start_dir = (main_search < CMS_user ? &pfile->no_search_path
+ : search_path_head (pfile, fname, angle, IT_CMDLINE));
pfile->main_file
- = _cpp_find_file (pfile, fname,
- CPP_OPTION (pfile, preprocessed) ? &pfile->no_search_path
- : CPP_OPTION (pfile, main_search) == CMS_user
- ? pfile->quote_include
- : CPP_OPTION (pfile, main_search) == CMS_system
- ? pfile->bracket_include : &pfile->no_search_path,
- /*angle=*/0, _cpp_FFK_NORMAL, 0);
+ = _cpp_find_file (pfile, fname, start_dir, angle, _cpp_FFK_NORMAL, 0);
if (_cpp_find_failed (pfile->main_file))
return NULL;
int angle, _cpp_find_file_kind, location_t);
extern bool _cpp_find_failed (_cpp_file *);
extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *);
+extern cpp_dir *search_path_head (cpp_reader *, const char *, int,
+ include_type, bool = false);
extern const char *_cpp_find_header_unit (cpp_reader *, const char *file,
bool angle_p, location_t);
extern int _cpp_stack_embed (cpp_reader *, const char *, bool,