Skip to content

Commit 409f201

Browse files
committed
Allow redefinition of identical preprocessor macros
1 parent 2c9464f commit 409f201

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

source/effect_preprocessor.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,20 @@ void reshadefx::preprocessor::add_include_path(const std::filesystem::path &path
119119
assert(!path.empty());
120120
_include_paths.push_back(path);
121121
}
122-
bool reshadefx::preprocessor::add_macro_definition(const std::string &name, const macro &macro)
122+
bool reshadefx::preprocessor::add_macro_definition(const std::string &name, const macro &new_macro)
123123
{
124124
assert(!name.empty());
125-
return _macros.emplace(name, macro).second;
125+
const auto insert = _macros.emplace(name, new_macro);
126+
if (insert.second)
127+
return true;
128+
// Allow redefinition of identical macros
129+
const macro &existing_macro = insert.first->second;
130+
return
131+
existing_macro.replacement_list == new_macro.replacement_list &&
132+
existing_macro.parameters == new_macro.parameters &&
133+
existing_macro.is_predefined == new_macro.is_predefined &&
134+
existing_macro.is_variadic == new_macro.is_variadic &&
135+
existing_macro.is_function_like == new_macro.is_function_like;
126136
}
127137

128138
bool reshadefx::preprocessor::append_file(const std::filesystem::path &path)

0 commit comments

Comments
 (0)