diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index ad25d817e0..bd18331e23 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1715,6 +1715,12 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { } else { _last_c = '\0'; + // If it was explicitly named on the command-line, mark it S_local. + filename.make_absolute(); + if (_explicit_files.count(filename)) { + source = CPPFile::S_local; + } + CPPFile file(filename, filename_as_referenced, source); // Don't include it if we included it before and it had #pragma once. diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index 189de37650..6ad18c1bba 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -88,6 +88,8 @@ public: Includes _quote_includes; Includes _angle_includes; + set _explicit_files; + // This is normally true, to indicate that the preprocessor should // decode identifiers like foo::bar into a single IDENTIFIER, // TYPENAME_IDENTIFIER, or SCOPING token for yacc's convenience. diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 515b149437..92b543f3e6 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -506,9 +506,15 @@ main(int argc, char **argv) { build_c_wrappers = true; } - // Get all of the .h files. - for (i = 1; i < argc; ++i) - { + // Add all of the .h files we are explicitly including to the parser. + for (i = 1; i < argc; ++i) { + Filename filename = Filename::from_os_specific(argv[i]); + filename.make_absolute(); + parser._explicit_files.insert(filename); + } + + // Now go through them again and feed them into the C++ parser. + for (i = 1; i < argc; ++i) { Filename filename = Filename::from_os_specific(argv[i]); if (!parser.parse_file(filename)) { cerr << "Error parsing file: '" << argv[i] << "'\n";