summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libwebp/src/webp/types.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libwebp/src/webp/types.h')
-rw-r--r--src/3rdparty/libwebp/src/webp/types.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/3rdparty/libwebp/src/webp/types.h b/src/3rdparty/libwebp/src/webp/types.h
index 47f7f2b..9c17ede 100644
--- a/src/3rdparty/libwebp/src/webp/types.h
+++ b/src/3rdparty/libwebp/src/webp/types.h
@@ -36,14 +36,39 @@ typedef long long int int64_t;
#define WEBP_INLINE __forceinline
#endif /* _MSC_VER */
+#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
+// gcc's __has_attribute does not work for enums.
+#if defined(__clang__) && defined(__has_attribute)
+#if __has_attribute(warn_unused_result)
+#define WEBP_NODISCARD __attribute__((warn_unused_result))
+#else
+#define WEBP_NODISCARD
+#endif /* __has_attribute(warn_unused_result) */
+#else
+#define WEBP_NODISCARD
+#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
// signature for e.g., Windows DLL builds.
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(_WIN32) && defined(WEBP_DLL)
+# define WEBP_EXTERN __declspec(dllexport)
+# elif defined(__GNUC__) && __GNUC__ >= 4
# define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
# else
# define WEBP_EXTERN extern
-# endif /* __GNUC__ >= 4 */
+# endif /* defined(_WIN32) && defined(WEBP_DLL) */
#endif /* WEBP_EXTERN */
// Macro to check ABI compatibility (same major revision number)
@@ -56,7 +81,7 @@ extern "C" {
// Allocates 'size' bytes of memory. Returns NULL upon error. Memory
// must be deallocated by calling WebPFree(). This function is made available
// by the core 'libwebp' library.
-WEBP_EXTERN void* WebPMalloc(size_t size);
+WEBP_NODISCARD WEBP_EXTERN void* WebPMalloc(size_t size);
// Releases memory returned by the WebPDecode*() functions (from decode.h).
WEBP_EXTERN void WebPFree(void* ptr);