spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

daily_file_sink.h compilation error

Open andrascii opened this issue 7 months ago • 4 comments

Hi! Im encountered a compilation error (spdlog == 1.15.3) on MacOs with clang:

Homebrew clang version 20.1.6
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/20.1.6/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin23.cfg

Compilation errors:

[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/spdlog/sinks/daily_file_sink.h:34:32: error: call to consteval function 'fmt::basic_format_string<char, std::string &, int, int, const int &, std::string &>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
[build]    34 |         return fmt_lib::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{}_{:04d}-{:02d}-{:02d}{}")),
[build]       |                                ^
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/spdlog/common.h:55:46: note: expanded from macro 'SPDLOG_FMT_STRING'
[build]    55 |     #define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
[build]       |                                              ^
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/format.h:1827:23: note: expanded from macro 'FMT_STRING'
[build]  1827 | #define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string, )
[build]       |                       ^
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/format.h:1806:3: note: expanded from macro 'FMT_STRING_IMPL'
[build]  1806 |   [] {                                                                        \
[build]       |   ^
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/base.h:779:54: note: subexpression not valid in a constant expression
[build]   779 |     format_str_.remove_prefix(detail::to_unsigned(it - begin()));
[build]       |                                                   ~~~^~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/base.h:2761:5: note: in call to 'this->context_.advance_to(&"{}_{:04d}-{:02d}-{:02d}{}"[1])'
[build]  2761 |     context_.advance_to(begin);
[build]       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/base.h:2756:5: note: in call to 'this->on_format_specs(0, &"{}_{:04d}-{:02d}-{:02d}{}"[1], &"{}_{:04d}-{:02d}-{:02d}{}"[1])'
[build]  2756 |     on_format_specs(id, begin, begin);  // Call parse() on empty specs.
[build]       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/base.h:2581:5: note: in call to 'handler.on_replacement_field(0, &"{}_{:04d}-{:02d}-{:02d}{}"[1])'
[build]  2581 |     handler.on_replacement_field(handler.on_arg_id(), begin);
[build]       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/base.h:2613:21: note: in call to 'parse_replacement_field<char, fmt::detail::format_string_checker<char, std::string, int, int, int, std::string> &>(&"{}_{:04d}-{:02d}-{:02d}{}"[1], &"{}_{:04d}-{:02d}-{:02d}{}"[25], checker(s))'
[build]  2613 |         begin = p = parse_replacement_field(p - 1, end, handler);
[build]       |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/base.h:2884:7: note: in call to 'parse_format_string<true, char, fmt::detail::format_string_checker<char, std::string, int, int, int, std::string>>({&"{}_{:04d}-{:02d}-{:02d}{}"[0], 25}, checker(s))'
[build]  2884 |       detail::parse_format_string<true>(str_, checker(s));
[build]       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/spdlog/sinks/daily_file_sink.h:34:32: note: in call to 'basic_format_string<FMT_COMPILE_STRING, 0>([] {
[build]     struct __attribute__((visibility("hidden")))  FMT_COMPILE_STRING : fmt::detail::compile_string {
[build]         using char_type [[maybe_unused]] = fmt::remove_cvref_t<decltype("{}_{:04d}-{:02d}-{:02d}{}"[0])>;
[build]         [[maybe_unused]] constexpr operator fmt::basic_string_view<char_type>() const {
[build]             return fmt::detail_exported::compile_string_to_view<char_type>("{}_{:04d}-{:02d}-{:02d}{}");
[build]         }
[build]     };
[build]     return FMT_COMPILE_STRING();
[build] }())'
[build]    34 |         return fmt_lib::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{}_{:04d}-{:02d}-{:02d}{}")),
[build]       |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/spdlog/common.h:55:46: note: expanded from macro 'SPDLOG_FMT_STRING'
[build]    55 |     #define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
[build]       |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/format.h:1827:23: note: expanded from macro 'FMT_STRING'
[build]  1827 | #define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string, )
[build]       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /Users/apugachev/work/repos/my/vpn-telegram-bot/build/vcpkg_installed/arm64-osx/include/fmt/format.h:1806:3: note: expanded from macro 'FMT_STRING_IMPL'
[build]  1806 |   [] {                                                                        \
[build]       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1807 |     /* Use the hidden visibility as a workaround for a GCC bug (#1973). */    \
[build]       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1808 |     /* Use a macro-like name to avoid shadowing warnings. */                  \
[build]       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1809 |     struct FMT_VISIBILITY("hidden") FMT_COMPILE_STRING : base {               \
[build]       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1810 |       using char_type FMT_MAYBE_UNUSED = fmt::remove_cvref_t<decltype(s[0])>; \
[build]       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1811 |       FMT_MAYBE_UNUSED FMT_CONSTEXPR explicit                                 \
[build]       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1812 |       operator fmt::basic_string_view<char_type>() const {                    \
[build]       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1813 |         return fmt::detail_exported::compile_string_to_view<char_type>(s);    \
[build]       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1814 |       }                                                                       \
[build]       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1815 |     };                                                                        \
[build]       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1816 |     return FMT_COMPILE_STRING();                                              \
[build]       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]  1817 |   }()
[build]       |   ~~~
[build] 1 error generated.

But with AppleClang 16.0.0 it compiles well.

andrascii avatar Jun 09 '25 08:06 andrascii

This is fmt problem, please reopen issue in the fmt repository.

Similar issue: fmtlib/fmt#4396

tt4g avatar Jun 09 '25 21:06 tt4g

It appears that vcpkg does not provide the latest fmt (v12):microsoft/vcpkg#45357 I think this problem will be solved when vcpkg releases the fmt v12.

tt4g avatar Jun 10 '25 03:06 tt4g

Just for the sake of information: worked fine on Arch's clang 19 with vcpkg, probably related to changes in clang 20

nic11 avatar Jun 13 '25 05:06 nic11

Thanks @tt4g!

Looks like they're struggling with v11 for a while already: https://github.com/microsoft/vcpkg/pull/45295

nic11 avatar Jun 13 '25 05:06 nic11