From 0f5a940e5bd56b84834553c125b8fcacd659e986 Mon Sep 17 00:00:00 2001 From: Richard Biely Date: Tue, 16 Jul 2024 14:47:04 +0200 Subject: [PATCH] Fixed: Dummy example build + stack allocator on MSVC --- include/gaia/mem/stack_allocator.h | 2 +- src/dummy/src/main.cpp | 6 ++++++ src/perf/duel/src/main.cpp | 2 +- src/test/src/main.cpp | 27 ++++++++++++++------------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/gaia/mem/stack_allocator.h b/include/gaia/mem/stack_allocator.h index 60edbf2b..c889847d 100644 --- a/include/gaia/mem/stack_allocator.h +++ b/include/gaia/mem/stack_allocator.h @@ -83,7 +83,7 @@ namespace gaia { core::call_ctor_raw_n(pData, cnt); // Allocation start offset - m_posPrev = addrAllocInfo - addrBuff; + m_posPrev = (uint32_t)(addrAllocInfo - addrBuff); // Point to the next free space (not necessary alligned yet) m_pos = m_posPrev + pInfo->off + sizeT * cnt; diff --git a/src/dummy/src/main.cpp b/src/dummy/src/main.cpp index 429f6ff8..0897b23b 100644 --- a/src/dummy/src/main.cpp +++ b/src/dummy/src/main.cpp @@ -327,14 +327,17 @@ void test0() { auto q1 = w.query().all(); const auto c1 = q1.count(); GAIA_ASSERT(c1 == 2); + (void)c1; auto q2 = w.query().all(); const auto c2 = q2.count(); GAIA_ASSERT(c2 == 3); + (void)c2; auto q3 = w.query().no(); const auto c3 = q3.count(); GAIA_ASSERT(c3 > 0); // It's going to be a bunch + (void)c3; } } @@ -354,6 +357,7 @@ void test1() { auto q = w.query().add({ecs::QueryOp::All, ecs::QueryAccess::None, ecs::Pair(eats, ecs::All)}); const auto cnt = q.count(); GAIA_ASSERT(cnt == 3); + (void)cnt; uint32_t i = 0; q.each([&](ecs::Entity entity) { @@ -362,6 +366,7 @@ void test1() { const bool isWolf = entity == wolf; const bool is = isRabbit || isHare || isWolf; GAIA_ASSERT(is); + (void)is; ++i; }); GAIA_ASSERT(i == cnt); @@ -463,6 +468,7 @@ void test5() { w.del(e); const bool isEntityValid = w.valid(e); GAIA_ASSERT(!isEntityValid); + (void)isEntityValid; }; GAIA_FOR(N) create(i); diff --git a/src/perf/duel/src/main.cpp b/src/perf/duel/src/main.cpp index ba7f18bd..a6bb09ac 100644 --- a/src/perf/duel/src/main.cpp +++ b/src/perf/duel/src/main.cpp @@ -845,13 +845,13 @@ void BM_NonECS(picobench::state& state) { } { GAIA_PROF_SCOPE(calc_alive); - uint32_t aliveUnits = 0; for (auto& u: units) { if (u->isAlive()) ++aliveUnits; } } } + (void)aliveUnits; units[0]->updatePosition_verify(); units[0]->handleGroundCollision_verify(); diff --git a/src/test/src/main.cpp b/src/test/src/main.cpp index dd10d649..14941725 100644 --- a/src/test/src/main.cpp +++ b/src/test/src/main.cpp @@ -2877,9 +2877,8 @@ TEST_CASE("Query - QueryResult complex") { } TEST_CASE("Relationship") { - TestWorld twld; - SECTION("Simple") { + TestWorld twld; auto wolf = wld.add(); auto rabbit = wld.add(); auto carrot = wld.add(); @@ -2935,6 +2934,7 @@ TEST_CASE("Relationship") { } SECTION("Simple - bulk") { + TestWorld twld; auto wolf = wld.add(); auto rabbit = wld.add(); auto carrot = wld.add(); @@ -2978,6 +2978,7 @@ TEST_CASE("Relationship") { } SECTION("Intermediate") { + TestWorld twld; auto wolf = wld.add(); auto hare = wld.add(); auto rabbit = wld.add(); @@ -3096,7 +3097,7 @@ TEST_CASE("Relationship") { REQUIRE(cnt == 0); uint32_t i = 0; - q.each([&](ecs::Iter& it) { + q.each([&]([[maybe_unused]] ecs::Iter& it) { ++i; }); REQUIRE(i == 0); @@ -3107,7 +3108,7 @@ TEST_CASE("Relationship") { REQUIRE(cnt == 1); uint32_t i = 0; - q.each([&](ecs::Iter& it) { + q.each([&]([[maybe_unused]] ecs::Iter& it) { ++i; }); REQUIRE(i == 1); @@ -6846,23 +6847,23 @@ TEST_CASE("StackAllocator") { auto* pPos = a.alloc(10); GAIA_FOR(10) { - pPos[i].x = i; - pPos[i].y = i + 1; - pPos[i].z = i + 2; + pPos[i].x = (float)i; + pPos[i].y = (float)i + 1.f; + pPos[i].z = (float)i + 2.f; } a.free(pPos, 10); pPos = a.alloc(10); GAIA_FOR(10) { - REQUIRE(pPos[i].x == i); - REQUIRE(pPos[i].y == i + 1); - REQUIRE(pPos[i].z == i + 2); + REQUIRE(pPos[i].x == (float)i); + REQUIRE(pPos[i].y == (float)i + 1.f); + REQUIRE(pPos[i].z == (float)i + 2.f); } auto* pPosN = a.alloc(3); GAIA_FOR(3) { - REQUIRE(pPosN[i].x == 1); - REQUIRE(pPosN[i].y == 2); - REQUIRE(pPosN[i].z == 3); + REQUIRE(pPosN[i].x == 1.f); + REQUIRE(pPosN[i].y == 2.f); + REQUIRE(pPosN[i].z == 3.f); } // Alloc and release some more objects