diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 97076caa81..2b4a502365 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -2180,8 +2180,12 @@ expand_manifest(const CPPManifest *manifest, const YYLTYPE &loc) { manifest->_variadic_param, args); } - string expanded = " " + manifest->expand(args) + " "; - push_string(expanded, true); + // Perform expansion on the macro arguments. + for (string &arg : args) { + std::set expanded; + expanded.insert(manifest); + r_expand_manifests(arg, false, loc, expanded); + } string expanded = " " + manifest->expand(args) + " "; push_expansion(expanded, manifest, loc); @@ -2228,6 +2232,13 @@ r_expand_manifests(string &expr, bool expand_undefined, manifest->_variadic_param, args, expr, p); } + // Perform expansion on the macro arguments. + for (string &arg : args) { + std::set ignore = expanded; + ignore.insert(manifest); + r_expand_manifests(arg, expand_undefined, loc, ignore); + } + string result = manifest->expand(args); // Recurse, but adding the manifest we just expanded to the list