forked from MusicPlayerDaemon/MPD
-
Notifications
You must be signed in to change notification settings - Fork 0
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
[pull] master from MusicPlayerDaemon:master #17
Merged
Merged
Conversation
This file contains 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
When compiling with libfmt-11.1.0 and newer the following compile errors occur: In file included from ../src/decoder/DecoderPrint.cxx:23: ../src/client/Response.hxx: In instantiation of 'bool Response::Fmt(const S&, Args&& ...) [with S = decoder_plugin_print(Response&, const DecoderPlugin&)::<lambda()>::FMT_COMPILE_STRING; Args = {const char* const&}]': ../src/decoder/DecoderPrint.cxx:38:7: required from here 38 | r.Fmt(FMT_STRING("plugin: {}\n"), plugin.name); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/client/Response.hxx:86:28: error: cannot convert 'const decoder_plugin_print(Response&, const DecoderPlugin&)::<lambda()>::FMT_COMPILE_STRING' to 'fmt::v11::string_view' {aka 'fmt::v11::basic_string_view<char>'} 86 | return VFmt(format_str, | ~~~~^~~~~~~~~~~~ 87 | fmt::make_format_args(args...)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/client/Response.hxx:81:36: note: initializing argument 1 of 'bool Response::VFmt(fmt::v11::string_view, fmt::v11::format_args)' 81 | bool VFmt(fmt::string_view format_str, fmt::format_args args) noexcept; | ~~~~~~~~~~~~~~~~~^~~~~~~~~~ ../src/client/Response.hxx: In instantiation of 'bool Response::Fmt(const S&, Args&& ...) [with S = decoder_plugin_print(Response&, const DecoderPlugin&)::<lambda()>::FMT_COMPILE_STRING; Args = {const char* const&}]': The error is due to the use of FMT_STRING. The libfmt team shared the following: The correct way of using FMT_STRING is to wrap a format string when passing to a function with compile-time checks (i.e. that takes format_string) as documented in https://fmt.dev/11.1/api/#legacy-compile-time-checks. Noting that FMT_STRING is a legacy API and has been superseded by consteval-based API starting from version 8: https://github.com/fmtlib/fmt/releases/tag/8.0.0. It looks like MPD is trying to emulate {fmt}'s old way of implementing compile-time checks which was never properly documented because it was basically a hack. So the correct fix is to switch to format_string and, possibly, remove usage of FMT_STRING. The old way of doing compile-time checks (fmt::make_args_checked) was documented in https://fmt.dev/7.1/api.html#argument-lists but it looks like MPD is not using that API so the problematic uses of FMT_STRING have no effect and can just be removed. The FMT_STRING has been removed in this change based on the fmt-7.1 API and now MPD is successfully compile against the current libfmt-11.1.0 which highlighted the issue that had been present in the codebase as it is now triggering the error, is legacy and was not using the API for which FMT_STRING was aligned with.
Minor revert of 9db7144 - no change was to be done to meson.build.
Fixes: 9db7144 Signed-off-by: Alfred Wingate <[email protected]>
MPD stopped building since fmt 11.1.0; see <fmtlib/fmt#4304>. The first commit fixing this was 9db7144, followed by 5de0909 (both on the unstable branch). This commit removes what the author believes to be the remaining uses in the MPD codebase.
Reviewer's Guide by SourceryThis pull request refactors the code to use the new fmt library for formatting strings. This change improves code readability and maintainability by using a more modern and type-safe approach to string formatting. Class diagram showing the Response class changesclassDiagram
class Response {
+Write(text: string)
+WriteBinary(payload: span<byte>)
+Error(code: ack, msg: string)
+VFmtError(code: ack, format_str: string_view, args: format_args)
+Fmt(format_str: string_view, ...args)
-old_fmt_string FMT_STRING(str) removed
note for Response "Changed from FMT_STRING macro
to direct string literals for fmt""
}
Flow diagram showing string formatting changesgraph TD
A[Old Format Style] -->|Refactored| B[New Format Style]
A -->|Uses| C[FMT_STRING macro]
B -->|Uses| D[Direct string literals]
C -->|Removed| E[Simplified formatting]
D -->|Provides| F[Type-safe formatting]
F -->|Improves| G[Code maintainability]
F -->|Enhances| H[Code readability]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Chores: