Jak naprawić ten warning ?

0

kod wygląda tak

#include <fstream>
#include <spdlog/spdlog.h>
void test()
{
    spdlog::warn("test");
}

kompilator clang 18.1.1 z msys2 , spdlog i fmt ostanie wersje dodane przez add_subdirecotry

niedawno zmienila sie wersja kompilatora i wyskoczyło masę podobnych warningów

[main] Building folder: bug_fmt 
[build] Starting build
[proc] Executing command: C:\msys64\clang64\bin\cmake.EXE --build d:/bug_fmt/build --config Debug --target all --
[build] [1/2  50% :: 1.216] Building CXX object CMakeFiles/bug_fmt.dir/sysutilsX.cpp.obj
[build] In file included from D:/bug_fmt/sysutilsX.cpp:1:
[build] In file included from C:/msys64/clang64/include/c++/v1/fstream:194:
[build] In file included from C:/msys64/clang64/include/c++/v1/__locale:23:
[build] In file included from C:/msys64/clang64/include/c++/v1/string:625:
[build] In file included from C:/msys64/clang64/include/c++/v1/string_view:213:
[build] C:/msys64/clang64/include/c++/v1/__fwd/string_view.h:22:41: warning: 'char_traits<fmt::detail::char8_type>' is deprecated: char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 19, so please migrate off of it. [-Wdeprecated-declarations]
[build]    22 | template <class _CharT, class _Traits = char_traits<_CharT> >
[build]       |                                         ^
[build] D:/bug_fmt/spdlog/include/spdlog/fmt/bundled/core.h:377:26: note: in instantiation of default argument for 'basic_string_view<fmt::detail::char8_type>' required here
[build]   377 | template <typename Char> using std_string_view = std::basic_string_view<Char>;
[build]       |                          ^~~~~
[build] D:/bug_fmt/spdlog/include/spdlog/fmt/bundled/core.h:467:50: note: in instantiation of template type alias 'std_string_view' requested here
[build]   467 |                                       S, detail::std_string_view<Char>>::value)>
[build]       |                                                  ^
[build] D:/bug_fmt/spdlog/include/spdlog/fmt/bundled/format.h:713:57: note: in instantiation of template class 'fmt::basic_string_view<fmt::detail::char8_type>' requested here
[build]   713 | inline auto compute_width(basic_string_view<char8_type> s) -> size_t {
[build]       |                                                         ^
[build] C:/msys64/clang64/include/c++/v1/__string/char_traits.h:81:8: note: 'char_traits<fmt::detail::char8_type>' has been explicitly marked deprecated here
[build]    81 | struct _LIBCPP_DEPRECATED_(
[build]       |        ^
[build] C:/msys64/clang64/include/c++/v1/__config:975:53: note: expanded from macro '_LIBCPP_DEPRECATED_'
[build]   975 | #      define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
[build]       |                                                     ^
[build] 1 warning generated.
[build] [2/2 100% :: 1.407] Linking CXX executable bug_fmt.exe
[driver] Build completed: 00:00:01.474
[build] Build finished with exit code 0

I repozytorium https://github.com/mariuszmaximus/bug_fmt

Ja sie poddałem :(

0

The warning suggests that you should migrate away from this usage because it will be removed in LLVM 19. Here are some steps you might take to address this warning:

Update Code: If you're directly using char_traitsfmt::detail::char8_type, update your code to use the standard types mentioned in the warning.

Library Update: If this usage is coming from a library, check if there's an updated version of the library available that addresses this deprecation.

Custom Implementation: If necessary, consider implementing your own char_traits specialization that adheres to the standard types, especially if the library or codebase you're using heavily relies on the deprecated usage.

Here's an example of what a migration might look like:

// Old usage
using char_traits_type = char_traits<fmt::detail::char8_type>;

// Migration
using char_traits_type = std::char_traits<fmt::detail::char8_type>;

Replace fmt::detail::char8_type with one of the standard types like char, wchar_t, char8_t, char16_t, or char32_t, depending on your specific requirements.

0

A co masz przy np. spdlog::warn(std::string("test")); ?

0

OK ! juz to poprawiono https://github.com/fmtlib/fmt/commit/800a0bb23f0bb45bfabecb4236bd1a3f40f9632d
tylko jeszcze nie było nowej wersji od czasu tej poprawki

0

Jaką masz wersję spdlog bo nie jestem w stanie odtworzyć: https://godbolt.org/z/hYnjhP4Mc

0

@MarekR22: na godbolt nie bylem w stanie powtórzyć tego błędu wiec zakładam ze ma to trochę związek z moja niestandardową platformą msys2:mingw-w64-clang-x86_64-clang
jeżeli chodzi o wersję to miałem
fmt: 10.2.1
spdlog: 1:13 budowany z ustawioną opcją SPDLOG_FMT_EXTERNAL

Zaktuzlizowanie fmt do dzisiejszej wersji z git-a rozwiązało problem

1 użytkowników online, w tym zalogowanych: 0, gości: 1