Skip to content
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

vcpkg: Compilation error when using fmt::styled with fmt::print #183

Closed
ghost opened this issue Sep 22, 2024 · 3 comments · Fixed by #185
Closed

vcpkg: Compilation error when using fmt::styled with fmt::print #183

ghost opened this issue Sep 22, 2024 · 3 comments · Fixed by #185

Comments

@ghost
Copy link

ghost commented Sep 22, 2024

The following error message is displayed during compilation (output.cpp:104):

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\include\xutility(1190,54):
error C2794: 'reference': is not a member of any direct or indirect base class of 'std::iterator_traits<fmt::v11::appender>'
error C2938: 'std::_Iter_ref_t' : Failed to specialize alias template
error C2062: type 'unknown-type' unexpected
error C3376: 'std::_Iterator_is_volatile': only static data member templates are allowed
error C2976: 'std::_Iter_copy_cat': too few template arguments
error C2039: '_Bitcopy_assignable': is not a member of '`global namespace''

Here is the latest version of format.h in the fmtlib:

namespace std {
template <> struct iterator_traits<fmt::appender> {
  using iterator_category = output_iterator_tag;
  using value_type = char;
  using reference = char&;
  using difference_type = fmt::appender::difference_type;
};
}  // namespace std

The version of format.h in vcpkg-export-20240826-223407.zip is as follows:

namespace std {
template <> struct iterator_traits<fmt::appender> {
  using iterator_category = output_iterator_tag;
  using value_type = char;
  // Missing reference and difference_type
};
}  // namespace std

My guess about the cause of the above error is that the missing reference and difference_type may be contributing factors, but I don't know how to resolve this issue. Simply removing the use of fmt::styled allows the compilation to succeed.

@Ghabry
Copy link
Member

Ghabry commented Sep 22, 2024

That's a bug in fmtlib fmtlib/fmt#4091

There is no new release of fmtlib yet so you can keep your workaround until they release a new version.

@ghost
Copy link
Author

ghost commented Sep 22, 2024

The issue can be temporarily resolved by adding the missing using reference = char&;.

@ghost ghost closed this as completed Sep 22, 2024
@carstene1ns
Copy link
Member

I think it would be good to keep this open until we have either the next version of fmt in vcpkg or we would need to pin the version there.
(That is pinning vcpkg version, since package versions can only be specified with some JSON file which we do not use)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants