From ef623fd16fa8cb58e7a0f8c04af75ee8b3f2752f Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 16 Sep 2021 11:30:49 +0200 Subject: [PATCH] Fix __cpp_lib_hypot related error when building in macos If __cpp_lib_hypot is undefined in macos you may observe the error: error: '__cpp_lib_hypot' is not defined, evaluates to 0 [-Werror,-Wundef] Adding the explicit check for definition suppresses the warning that is treated as an error. Change-Id: Ie4c185fefde2f5bab699d8fc79b6a170e64af393 Reviewed-by: Andrei Golubev Reviewed-by: Edward Welbourne Reviewed-by: Giuseppe D'Angelo Reviewed-by: Ievgenii Meshcheriakov --- src/corelib/global/qfloat16.h | 2 +- src/corelib/kernel/qmath.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index c2e5379eb42..59739fdcc12 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -333,7 +333,7 @@ template <> inline auto qHypot(qfloat16 x, qfloat16 y) return qfloat16(qHypot(float(x), float(y))); #endif } -#if __cpp_lib_hypot >= 201603L // Expected to be true +#if defined(__cpp_lib_hypot) && __cpp_lib_hypot >= 201603L // Expected to be true // If any are not qfloat16, convert each qfloat16 to float: /* (The following splits the some-but-not-all-qfloat16 cases up, using (X|Y|Z)&~(X&Y&Z) = X ? ~(Y&Z) : Y|Z = X&~(Y&Z) | ~X&Y | ~X&~Y&Z, diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index 18530714e0b..5e8d4fc2767 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -192,7 +192,7 @@ auto qHypot(Tx x, Ty y) return hypot(x, y); } -#if __cpp_lib_hypot >= 201603L // Expected to be true +#if defined(__cpp_lib_hypot) && __cpp_lib_hypot >= 201603L // Expected to be true template auto qHypot(Tx x, Ty y, Tz z) {