SDL: Add `SDL_NODISCARD` macro to `SDL_begin_code.h`

From a69eaae32ebcc87b8aa8da275a4856972e34fb69 Mon Sep 17 00:00:00 2001
From: vittorioromeo <[EMAIL REDACTED]>
Date: Fri, 17 May 2024 01:46:57 +0200
Subject: [PATCH] Add `SDL_NODISCARD` macro to `SDL_begin_code.h`

---
 include/SDL3/SDL_begin_code.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h
index e2a7ce48a39b1..36b9e188d259e 100644
--- a/include/SDL3/SDL_begin_code.h
+++ b/include/SDL3/SDL_begin_code.h
@@ -171,6 +171,19 @@
 #endif /* C++17 or C2x */
 #endif /* SDL_FALLTHROUGH not defined */
 
+#ifndef SDL_NODISCARD
+#if (defined(__cplusplus) && __cplusplus >= 201703L) || \
+    (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
+#define SDL_NODISCARD [[nodiscard]]
+#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
+#define SDL_NODISCARD __attribute__((warn_unused_result))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1700)
+#define SDL_NODISCARD _Check_return_
+#else
+#define SDL_NODISCARD
+#endif /* C++17 or C23 */
+#endif /* SDL_NODISCARD not defined */
+
 #ifndef SDL_MALLOC
 #if defined(__GNUC__) && (__GNUC__ >= 3)
 #define SDL_MALLOC __attribute__((malloc))