From 3132c96a80d9273a6a6f88131b3d475273b4f2e4 Mon Sep 17 00:00:00 2001 From: Chairn Date: Sun, 25 Dec 2022 20:41:19 +0100 Subject: [PATCH] Use own defines of format specifiers for MinGW (fixes #6187) --- src/base/system.h | 11 +++++++++++ .../client/backend/vulkan/backend_vulkan.cpp | 14 +++++++------- src/engine/client/client.cpp | 5 ----- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/base/system.h b/src/base/system.h index fc2d324c2..aaa4ef1de 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -14,9 +14,20 @@ #define __USE_GNU #endif +#include #include #include +#ifdef __MINGW32__ +#undef PRId64 +#undef PRIu64 +#define PRId64 "I64d" +#define PRIu64 "I64u" +#define PRIzu "Iu" +#else +#define PRIzu "zu" +#endif + #ifdef CONF_FAMILY_UNIX #include #endif diff --git a/src/engine/client/backend/vulkan/backend_vulkan.cpp b/src/engine/client/backend/vulkan/backend_vulkan.cpp index 36b240a38..6f7c23ae3 100644 --- a/src/engine/client/backend/vulkan/backend_vulkan.cpp +++ b/src/engine/client/backend/vulkan/backend_vulkan.cpp @@ -87,7 +87,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase break; default: break; } - dbg_msg("vulkan", "allocated chunk of memory with size: %zu for frame %zu (%s)", (size_t)Size, (size_t)m_CurImageIndex, pUsage); + dbg_msg("vulkan", "allocated chunk of memory with size: %" PRIzu " for frame %" PRIzu " (%s)", (size_t)Size, (size_t)m_CurImageIndex, pUsage); } void VerboseDeallocatedMemory(VkDeviceSize Size, size_t FrameImageIndex, EMemoryBlockUsage MemUsage) @@ -109,7 +109,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase break; default: break; } - dbg_msg("vulkan", "deallocated chunk of memory with size: %zu for frame %zu (%s)", (size_t)Size, (size_t)m_CurImageIndex, pUsage); + dbg_msg("vulkan", "deallocated chunk of memory with size: %" PRIzu " for frame %" PRIzu " (%s)", (size_t)Size, (size_t)m_CurImageIndex, pUsage); } /************************ @@ -2057,7 +2057,7 @@ protected: m_pStagingMemoryUsage->store(m_pStagingMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed); if(IsVerbose()) { - dbg_msg("vulkan", "deallocated chunks of memory with size: %zu from all frames (staging buffer)", (size_t)FreeedMemory); + dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (staging buffer)", (size_t)FreeedMemory); } } FreeedMemory = 0; @@ -2067,7 +2067,7 @@ protected: m_pBufferMemoryUsage->store(m_pBufferMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed); if(IsVerbose()) { - dbg_msg("vulkan", "deallocated chunks of memory with size: %zu from all frames (buffer)", (size_t)FreeedMemory); + dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (buffer)", (size_t)FreeedMemory); } } FreeedMemory = 0; @@ -2078,7 +2078,7 @@ protected: m_pTextureMemoryUsage->store(m_pTextureMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed); if(IsVerbose()) { - dbg_msg("vulkan", "deallocated chunks of memory with size: %zu from all frames (texture)", (size_t)FreeedMemory); + dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (texture)", (size_t)FreeedMemory); } } } @@ -3817,7 +3817,7 @@ public: if(IsVerbose()) { - dbg_msg("vulkan", "device prop: non-coherent align: %zu, optimal image copy align: %zu, max texture size: %u, max sampler anisotropy: %u", (size_t)m_NonCoherentMemAlignment, (size_t)m_OptimalImageCopyMemAlignment, m_MaxTextureSize, m_MaxSamplerAnisotropy); + dbg_msg("vulkan", "device prop: non-coherent align: %" PRIzu ", optimal image copy align: %" PRIzu ", max texture size: %u, max sampler anisotropy: %u", (size_t)m_NonCoherentMemAlignment, (size_t)m_OptimalImageCopyMemAlignment, m_MaxTextureSize, m_MaxSamplerAnisotropy); dbg_msg("vulkan", "device prop: min uniform align: %u, multi sample: %u", m_MinUniformAlign, (uint32_t)m_MaxMultiSample); } } @@ -7634,7 +7634,7 @@ public: if(IsVerbose() && s_BenchmarkRenderThreads) { - dbg_msg("vulkan", "render thread %zu took %d ns to finish", ThreadIndex, (int)(time_get_nanoseconds() - ThreadRenderTime).count()); + dbg_msg("vulkan", "render thread %" PRIzu " took %d ns to finish", ThreadIndex, (int)(time_get_nanoseconds() - ThreadRenderTime).count()); } pThread->m_IsRendering = false; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 9ce7ccfd9..b7891cd9c 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -70,11 +70,6 @@ #include "base/hash.h" -// for msvc -#ifndef PRIu64 -#define PRIu64 "I64u" -#endif - #include #include