win32/HResult: use libfmt

This commit is contained in:
Max Kellermann 2023-03-06 19:59:58 +01:00
parent c8f54b3509
commit b773ef3f0f
2 changed files with 6 additions and 4 deletions

View File

@ -8,8 +8,9 @@
#include "HResult.hxx" #include "HResult.hxx"
#include <fmt/core.h>
#include <cassert> #include <cassert>
#include <cstdio>
#include <combaseapi.h> // needed by audiopolicy.h if COM_NO_WINDOWS_H is defined #include <combaseapi.h> // needed by audiopolicy.h if COM_NO_WINDOWS_H is defined
#include <audiopolicy.h> #include <audiopolicy.h>
@ -69,7 +70,5 @@ HResultCategory::message(int Errcode) const
if (!msg.empty()) if (!msg.empty())
return std::string(msg); return std::string(msg);
int size = snprintf(buffer, sizeof(buffer), "0x%1x", Errcode); return fmt::format("{:#x}", Errcode);
assert(2 <= size && size <= 10);
return std::string(buffer, size);
} }

View File

@ -10,6 +10,9 @@ win32 = static_library(
'PropVariant.cxx', 'PropVariant.cxx',
'WinEvent.cxx', 'WinEvent.cxx',
include_directories: inc, include_directories: inc,
dependencies: [
fmt_dep,
],
) )
win32_dep = declare_dependency( win32_dep = declare_dependency(