From 9584cb7ac2083ab01e8c05cb7cde00cd5a77b55f Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 5 Feb 2022 16:24:57 +0100 Subject: [PATCH] Use fixed size types for serialization --- apps/openmw_test_suite/serialization/format.hpp | 5 +++-- components/serialization/format.hpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/openmw_test_suite/serialization/format.hpp b/apps/openmw_test_suite/serialization/format.hpp index 8f61838fde..603d2790e0 100644 --- a/apps/openmw_test_suite/serialization/format.hpp +++ b/apps/openmw_test_suite/serialization/format.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace SerializationTesting { @@ -20,7 +21,7 @@ namespace SerializationTesting } }; - enum Enum + enum Enum : std::int32_t { A, B, @@ -30,7 +31,7 @@ namespace SerializationTesting struct Composite { short mFloatArray[3] = {0}; - std::vector mIntVector; + std::vector mIntVector; std::vector mEnumVector; std::vector mPodVector; std::size_t mPodDataSize = 0; diff --git a/components/serialization/format.hpp b/components/serialization/format.hpp index 595afd0dad..956345149c 100644 --- a/components/serialization/format.hpp +++ b/components/serialization/format.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace Serialization { @@ -51,13 +52,13 @@ namespace Serialization -> std::enable_if_t> { if constexpr (mode == Mode::Write) - visitor(self(), value.size()); + visitor(self(), static_cast(value.size())); else { static_assert(mode == Mode::Read); - std::size_t size = 0; + std::uint64_t size = 0; visitor(self(), size); - value.resize(size); + value.resize(static_cast(size)); } self()(std::forward(visitor), value.data(), value.size()); }