From fbb133031949ecabe3a7b06e4b5a5f114745ec6e Mon Sep 17 00:00:00 2001 From: Evan Ramos Date: Thu, 10 Dec 2020 20:37:50 -0600 Subject: [PATCH] Avoid error with some toolchains where klabs(int16_t) turns into abs(double) --- source/build/include/pragmas.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 5a9f6f792..d08dd1896 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -264,7 +264,12 @@ static FORCE_INLINE int32_t klabs(int32_t const a) return (a ^ m) - m; } #else -#define klabs(x) abs(x) +# ifdef __cplusplus +// some toolchains use the double version of abs for small int types, so avoid that +static FORCE_INLINE CONSTEXPR int32_t klabs(int32_t const a) { return abs(a); } +# else +# define klabs(x) abs(x) +# endif #endif #endif #ifndef pragmas_have_ksgn -- GitLab