Skip to content

Commit

Permalink
Fix used preprocessor definitions no longer showing up after defining…
Browse files Browse the repository at this point in the history
… in preset
  • Loading branch information
crosire committed Feb 26, 2023
1 parent edf6d03 commit 3ba4533
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions source/effect_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,9 @@ void reshadefx::preprocessor::parse_ifdef()

_if_stack.push_back(std::move(level));
// Only add to used macro list if this #ifdef is active and the macro was not defined before
if (!parent_skipping && _macros.find(_token.literal_as_string) == _macros.end())
_used_macros.emplace(_token.literal_as_string);
if (!parent_skipping)
if (const auto it = _macros.find(_token.literal_as_string); it == _macros.end() || it->second.is_predefined)
_used_macros.emplace(_token.literal_as_string);
}
void reshadefx::preprocessor::parse_ifndef()
{
Expand All @@ -531,8 +532,9 @@ void reshadefx::preprocessor::parse_ifndef()

_if_stack.push_back(std::move(level));
// Only add to used macro list if this #ifndef is active and the macro was not defined before
if (!parent_skipping && _macros.find(_token.literal_as_string) == _macros.end())
_used_macros.emplace(_token.literal_as_string);
if (!parent_skipping)
if (const auto it = _macros.find(_token.literal_as_string); it == _macros.end() || it->second.is_predefined)
_used_macros.emplace(_token.literal_as_string);
}
void reshadefx::preprocessor::parse_elif()
{
Expand Down
3 changes: 2 additions & 1 deletion source/effect_preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace reshadefx
{
std::string replacement_list;
std::vector<std::string> parameters;
bool is_predefined = false;
bool is_variadic = false;
bool is_function_like = false;
};
Expand Down Expand Up @@ -52,7 +53,7 @@ namespace reshadefx
/// <returns></returns>
bool add_macro_definition(const std::string &name, std::string value = "1")
{
return add_macro_definition(name, macro { std::move(value), {} });
return add_macro_definition(name, macro { std::move(value), {}, true });
}

/// <summary>
Expand Down

0 comments on commit 3ba4533

Please sign in to comment.