diff options
author | James Zern <jzern@google.com> | 2024-04-11 12:34:46 -0700 |
---|---|---|
committer | James Zern <jzern@google.com> | 2024-04-11 12:34:46 -0700 |
commit | cf7c5a5de8a3b8616c5afd9848bd03e0e6a0b6c2 (patch) | |
tree | 87cf5bfb6359b2dac433a85c354fd990d8e82843 | |
parent | cc34288aa39a24a8a552126ad747121275f19b48 (diff) | |
download | webp-cf7c5a5de8a3b8616c5afd9848bd03e0e6a0b6c2.tar.gz |
provide a way to opt-out/override WEBP_NODISCARD
Bug: webp:627
Change-Id: I95ef89f37e5b7bf0f806bcfc6a295f5168b1bf67
-rw-r--r-- | src/webp/types.h | 16 |
1 files 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 |