From cf7c5a5de8a3b8616c5afd9848bd03e0e6a0b6c2 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 11 Apr 2024 12:34:46 -0700 Subject: [PATCH] provide a way to opt-out/override WEBP_NODISCARD Bug: webp:627 Change-Id: I95ef89f37e5b7bf0f806bcfc6a295f5168b1bf67 --- src/webp/types.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/webp/types.h b/src/webp/types.h index 0e7ef129..9c17edec 100644 --- a/src/webp/types.h +++ b/src/webp/types.h @@ -36,8 +36,9 @@ typedef long long int int64_t; #define WEBP_INLINE __forceinline #endif /* _MSC_VER */ -#if defined(WEBP_ENABLE_NODISCARD) || \ - (defined(__cplusplus) && __cplusplus >= 201700L) || \ +#ifndef WEBP_NODISCARD +#if defined(WEBP_ENABLE_NODISCARD) && WEBP_ENABLE_NODISCARD +#if (defined(__cplusplus) && __cplusplus >= 201700L) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) #define WEBP_NODISCARD [[nodiscard]] #else @@ -47,11 +48,16 @@ typedef long long int int64_t; #define WEBP_NODISCARD __attribute__((warn_unused_result)) #else #define WEBP_NODISCARD -#endif +#endif /* __has_attribute(warn_unused_result) */ #else #define WEBP_NODISCARD -#endif -#endif +#endif /* defined(__clang__) && defined(__has_attribute) */ +#endif /* (defined(__cplusplus) && __cplusplus >= 201700L) || + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) */ +#else +#define WEBP_NODISCARD +#endif /* defined(WEBP_ENABLE_NODISCARD) && WEBP_ENABLE_NODISCARD */ +#endif /* WEBP_NODISCARD */ #ifndef WEBP_EXTERN // This explicitly marks library functions and allows for changing the