-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change VariantUtility
to prevent undef print_verbose
#102062
base: master
Are you sure you want to change the base?
Conversation
Changes the `VariantUtility` function from `print_verbose` to `_print_verbose`, eliminating the need for undefining the `print_verbose` macro, which caused compilation problems.
a7b1493
to
aafcc4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your implementation is perfectly fine.
As a proposed solution to the problem, it's acceptable, but I think the solution I'd prefer would be to change the print_verbose
macro to a function:
template <typename... Args>
void print_verbose(const Variant &p_var, Args... p_args) {
if (is_print_verbose_enabled()) {
print_line(p_var, p_args...);
}
}
I have no idea why the snippet was made a macro in the first place (premature optimization?), but we can see now that it being one has led to awkward workarounds.
Yup a templated function was my first thought too, however I was suspecting the reason for using a define was to try and remove the work of the string concatenation: For instance
With a templated function, will it do the concatenation work, even though it will not be used further on? Or does the variable args remove this problem? With the define, if the There is a note about this in the source:
|
Right. That makes sense, I suppose. |
I do agree on capitalization for macros, mind you that approach might be subject to more push back (as the change is less localized), and will require rebasing existing PRs that use I wouldn't be surprised if this was historically a function and later changed to a macro for the string concat efficiency. Probably better for a separate PR though, so preferred approach can be chosen in a meeting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree on capitalization for macros, mind you that approach might be subject to more push back (as the change is less localized), and will require rebasing existing PRs that use print_verbose.
Agreed.
I see no reason to block this PR over there being another, possibly contentious solution. Your solution is self contained and unproblematic. The priority is fixing the bug, so I'm happy to approve.
I wouldn't be surprised if this was historically a function and later changed to a macro for the string concat efficiency.
I looked it up, that's correct!
Probably better for a separate PR though, so preferred approach can be chosen in a meeting.
Agreed!
Changes the
VariantUtility
function fromprint_verbose
to_print_verbose
, eliminating the need for undefining theprint_verbose
macro, which caused compilation problems.Fixes #101966
Notes
variant_utility.h
undefinedprint_verbose
.print_verbose
.Discussion
VariantUtility
contained aprint_verbose
function for binding (with gdscript etc) which conflicted with the global definition ofprint_verbose
. This had been worked around by undefiningprint_verbose
in these files, which was a little hacky, and had the side effect of breaking compilation in any later file that tried to useprint_verbose
.The more sensible solution was to give the
VariantUtility
function a different name. @Calinou informed me that it was possible to bind a function with a different name exposed to gdscript than the c++ function, and this (hopefully) provides the simplest solution.