Skip to content

Commit

Permalink
Fix compilation for fmtlib 8
Browse files Browse the repository at this point in the history
  • Loading branch information
nyanpasu64 committed Feb 16, 2022
1 parent cf3e495 commit 2101869
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/doc/validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ optional<size_t> validate_nchan_matches(
if (gen_nchan != metadata.nchan) {
PUSH_ERROR(state,
"[{0}].size()={1} != chips[{0}]={2}'s channel count ({3})",
chip_idx, gen_nchan, metadata.chip_kind, metadata.nchan
chip_idx, gen_nchan, (size_t) metadata.chip_kind, metadata.nchan
);
return {};
}
Expand Down
10 changes: 6 additions & 4 deletions src/doc/validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ class ErrorPrefixer {

/// See #define PUSH().
template <typename... Args>
void push(ErrorState & state, Args&&... args) const {
fmt::format_to(state.msg, std::forward<Args>(args)...);
void push(
ErrorState & state, fmt::format_string<Args...> str, Args&&... args
) const {
fmt::format_to(std::back_inserter(state.msg), str, std::forward<Args>(args)...);
}

/// See #define PUSH_LITERAL().
Expand Down Expand Up @@ -146,11 +148,11 @@ class ErrorPrefixer {
///
/// See #define PUSH_WARNING() and PUSH_ERROR().
template <ErrorType type, typename... Args>
void push_err_fmt(ErrorState & state, Args&&... args) {
void push_err_fmt(ErrorState & state, fmt::format_string<Args...> str, Args&&... args) {
size_t prefix = state.msg.size();

// push to end
fmt::format_to(state.msg, std::forward<Args>(args)...);
fmt::format_to(std::back_inserter(state.msg), str, std::forward<Args>(args)...);

// read message
state.err.push_back(Error{
Expand Down
6 changes: 4 additions & 2 deletions src/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,9 @@ optional<ChipList> load_chips(ErrorState & state, GenChips gen_chips) {
PUSH_FATAL(err, "[{}]=ChipKind::UNKNOWN, cannot load", i);
continue;
default:
PUSH_FATAL(err, "[{}]={} (unknown chip kind), cannot load", i, gen_chip);
PUSH_FATAL(err,
"[{}]={} (unknown chip kind), cannot load", i, (size_t) gen_chip
);
continue;
}

Expand Down Expand Up @@ -1234,7 +1236,7 @@ LoadDocumentResult load_impl(kj::InputStream & stream, ErrorState & state) {
default:
PUSH_WARNING(state,
"accidental_mode={} unrecognized (should be Sharp or Flat), defaulting to Sharp",
gen_accidental_mode
(size_t) gen_accidental_mode
);
return AccidentalMode::Sharp;
});
Expand Down

0 comments on commit 2101869

Please sign in to comment.