Skip to content

Commit

Permalink
scripting: Fix GCC workaround for "unused" var
Browse files Browse the repository at this point in the history
  • Loading branch information
caseif committed Jul 9, 2024
1 parent acce816 commit 0e24b60
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions engine/static/scripting/include/argus/scripting/bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,11 @@ namespace argus {
} else if constexpr (std::is_same_v<B, char>) {
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<FuncType>, "Unexpected pointer type for function return type");
}
} else if constexpr (std::is_same_v<std::remove_cv_t<ReturnType>, std::string>) {
ret_obj_size = ret.length();
} else {
// same workaround as above for GCC
UNUSED(ret_obj_type);
static_assert(always_false<FuncType>, "Unexpected type for function return type");
}
} else {
Expand Down Expand Up @@ -206,6 +198,12 @@ namespace argus {
"unbound element enum type").name;
}

// 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_type);

if constexpr (std::is_same_v<std::remove_cv_t<std::remove_pointer_t<
std::remove_reference_t<ReturnType>>>, std::string>) {
return create_object_wrapper(ret_obj_type, ret.c_str(), ret.size());
Expand Down

0 comments on commit 0e24b60

Please sign in to comment.