From 6f7af786421d760d74c6554374ac0df21b991225 Mon Sep 17 00:00:00 2001 From: Mathias Gibbens Date: Sat, 4 Mar 2023 15:51:08 +0000 Subject: [PATCH] Fix #17069: Fix build on ppc64el architectures (#19555) Co-authored-by: Mathias Gibbens --- src/openrct2/common.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/openrct2/common.h b/src/openrct2/common.h index 04b51cc00f..0038928dba 100644 --- a/src/openrct2/common.h +++ b/src/openrct2/common.h @@ -87,9 +87,17 @@ using money64 = fixed64_1dp; #define FIXED_1DP(whole, fraction) FIXED_XDP(1, whole, fraction) #define FIXED_2DP(whole, fraction) FIXED_XDP(10, whole, fraction) +// For a user defined floating point literal, the parameter type must be a +// `long double` which is problematic on ppc64el, as the architecture uses a +// pair of `doubles` to represent that type. This cannot be converted to a +// `constexpr`. As a workaround, statically cast the `long double` down to a +// `double`. All of the uses of _GBP constants fit just fine, and if anyone +// really tries to use a gigantic constant that can't fit in a double, they are +// probably going to be breaking other things anyways. +// For more details, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26374 constexpr money64 operator"" _GBP(long double money) noexcept { - return money * 10; + return static_cast(money) * 10; } constexpr money64 ToMoney64FromGBP(int32_t money) noexcept