From 48c9bc579c4fa62092522eb1102c1dc5e4281ef1 Mon Sep 17 00:00:00 2001 From: Max Roncace Date: Mon, 8 Jul 2024 22:03:51 -0400 Subject: [PATCH] scripting: Fix GCC workaround for "unused" var --- .../scripting/include/argus/scripting/bind.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/engine/static/scripting/include/argus/scripting/bind.hpp b/engine/static/scripting/include/argus/scripting/bind.hpp index 154fd13b..7162c422 100644 --- a/engine/static/scripting/include/argus/scripting/bind.hpp +++ b/engine/static/scripting/include/argus/scripting/bind.hpp @@ -142,6 +142,13 @@ namespace argus { auto ret_obj_type = create_return_object_type(); size_t ret_obj_size; + + // Older versions (<= 9) of GCC are too stupid to work out that + // this var doesn't need to be assigned in a branch that never + // returns to the parent scope, so we explicitly mark it unused + // here to prevent a compile error. + UNUSED(ret_obj_size); + if constexpr (std::is_same_v>>, std::string> || std::is_same_v) { ret_obj_size = strlen(ret); } else { - // GCC 9 is too stupid to work out that this var - // doesn't need to be assigned in a branch that - // never returns to the parent scope, so we - // explicitly mark it unused here to prevent a - // compile error - UNUSED(ret_obj_type); static_assert(always_false, "Unexpected pointer type for function return type"); } } else if constexpr (std::is_same_v, std::string>) { ret_obj_size = ret.length(); } else { - // same workaround as above for GCC - UNUSED(ret_obj_type); static_assert(always_false, "Unexpected type for function return type"); } } else {