Open
Conversation
| template <class... Args> | ||
| // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) | ||
| MsgStackItem(const std::string& file, int line, fmt::format_string<Args...> msg, | ||
| Args&&... args) |
Contributor
There was a problem hiding this comment.
warning: forwarding reference parameter 'args' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
Args&&... args)
^f64cbaa to
d4260cf
Compare
|
|
||
| #include <algorithm> | ||
| #include <clocale> | ||
| #include <csignal> |
Contributor
There was a problem hiding this comment.
warning: included header clocale is not used directly [misc-include-cleaner]
Suggested change
| #include <csignal> | |
| #include <csignal> |
src/bout++.cxx
Outdated
| #include <signal.h> | ||
| #include <sstream> | ||
| #include <stdexcept> | ||
| #include <stdio.h> |
Contributor
There was a problem hiding this comment.
warning: included header stdexcept is not used directly [misc-include-cleaner]
Suggested change
| #include <stdio.h> | |
| #include <stdio.h> |
Mostly involves using `fmt::vformat` with `fmt::make_format_args` in functions/ctors that act like `fmt::format`. Note that `fmt::make_format_args` requires lvalues, so although we take `Args&&` we _must not_ call `std::forward`. We also have to introduce a new gettext macro `_f` to allow compile-time format arg checking _and_ runtime i18n substitution.
d4260cf to
f509b78
Compare
| #include <signal.h> | ||
| #include <sstream> | ||
| #include <stdexcept> | ||
| #include <string> |
Contributor
There was a problem hiding this comment.
warning: included header stdexcept is not used directly [misc-include-cleaner]
Suggested change
| #include <string> | |
| #include <string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This uses a C++23 feature
if constevalif it's available to allow us to do compile-time format-string checking and use gettext's i18n. Ifif constevalisn't available, we fallback to just runtime checking.This feature is actually useful -- this commit fixes some bugs in a few output messages where the wrong number of format arguments were being passed!
However, the cost of this is that I've had to introduce a new macro,
_f, for gettext strings that are format-strings, because it doesn't play nice withoutput << _("something"). We should probably just deprecate and removeoutput <<anyway, but I didn't fancy fixing all of that right now.I've had to silence
cppcoreguidelines-missing-std-forwardin our formatting functions becausefmt::make_format_argsexplicitly requires this de-optimisation to avoid lifetime issues.Currently failing on CI because I think it does now actually need C++20 to build.Now into #3265 so that we can start using C++20