From c1498e9ab1ad4ad0f59f7ef7523931c312fe88c0 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 28 May 2024 12:11:03 +0200 Subject: [PATCH] common/Compiler: only define language keyword definitions if undefined --- src/common/Compiler.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/common/Compiler.h b/src/common/Compiler.h index 5e98abf24b..4bb210e89b 100644 --- a/src/common/Compiler.h +++ b/src/common/Compiler.h @@ -226,26 +226,34 @@ definition to detect its implementation was only added in C++17. */ #define NOEXCEPT noexcept #define NOEXCEPT_IF(x) noexcept(x) #define NOEXCEPT_EXPR(x) noexcept(x) -#else - #define NOEXCEPT - #define NOEXCEPT_IF(x) - #define NOEXCEPT_EXPR(x) x #endif // Uses SD-6 Feature Test Recommendations #if defined(__cpp_constexpr) #define CONSTEXPR constexpr #define CONSTEXPR_FUNCTION constexpr - #if __cpp_constexpr >= 201304 #define CONSTEXPR_FUNCTION_RELAXED constexpr - #else - #define CONSTEXPR_FUNCTION_RELAXED #endif -#else - // Work around lack of constexpr +#endif + +// Work around lack of language keywords. +#if !defined(NOEXCEPT) + #define NOEXCEPT +#endif +#if !defined(NOEXCEPT_IF) + #define NOEXCEPT_IF(x) +#endif +#if !defined(NOEXCEPT_EXPR) + #define NOEXCEPT_EXPR(x) x +#endif +#if !defined(CONSTEXPR) #define CONSTEXPR +#endif +#if !defined(CONSTEXPR_FUNCTION) #define CONSTEXPR_FUNCTION +#endif +#if !defined(CONSTEXPR_FUNCTION_RELAXED) #define CONSTEXPR_FUNCTION_RELAXED #endif