From f2a26aa4522a08121af08a72769617488f2eaf31 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Mon, 16 Jan 2023 15:08:37 +0100 Subject: [PATCH] Fix build with clang on debian 11 $ clang --version Debian clang version 11.0.1-2 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Fixes this error ``` In file included from /home/chiller/Desktop/git/ddnet/src/base/color.h:6: /home/chiller/Desktop/git/ddnet/src/base/vmath.h:141:38: error: constexpr function never produces a constant expression [-Winvalid-constexpr] constexpr inline vector2_base direction(float angle) ^ /home/chiller/Desktop/git/ddnet/src/base/vmath.h:143:29: note: non-constexpr function 'cosf' cannot be used in a constant expression return vector2_base(cosf(angle), sinf(angle)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:62:1: note: declared here __MATHCALL_VEC (cos,, (_Mdouble_ __x)); ^ /usr/include/math.h:266:3: note: expanded from macro '__MATHCALL_VEC' __MATHCALL (function, suffix, args) ^ /usr/include/math.h:273:3: note: expanded from macro '__MATHCALL' __MATHDECL (_Mdouble_,function,suffix, args) ^ /usr/include/math.h:275:3: note: expanded from macro '__MATHDECL' __MATHDECL_1(type, function,suffix, args); \ ^ /usr/include/math.h:283:15: note: expanded from macro '__MATHDECL_1' extern type __MATH_PRECNAME(function,suffix) args __THROW ^ /usr/include/math.h:303:34: note: expanded from macro '__MATH_PRECNAME' ^ :34:1: note: expanded from here cosf ^ 1 error generated. make[2]: *** [CMakeFiles/engine-shared.dir/build.make:173: CMakeFiles/engine-shared.dir/src/engine/shared/console.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:604: CMakeFiles/engine-shared.dir/all] Error 2 make: *** [Makefile:171: all] Error 2 ``` --- src/base/vmath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/vmath.h b/src/base/vmath.h index 84f97b179..5f5b932e7 100644 --- a/src/base/vmath.h +++ b/src/base/vmath.h @@ -138,7 +138,7 @@ inline vector2_base normalize(const vector2_base &v) return vector2_base(v.x * l, v.y * l); } -constexpr inline vector2_base direction(float angle) +inline vector2_base direction(float angle) { return vector2_base(cosf(angle), sinf(angle)); }