From 14b902faca5efd4141e73b2b0755f650213d9596 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 30 Nov 2022 11:33:32 +0300
Subject: [PATCH] begin_code.h: add gcc version checks to the alloc_size
attributes.
---
include/SDL3/begin_code.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/SDL3/begin_code.h b/include/SDL3/begin_code.h
index 064842913df4..0b23b57e286b 100644
--- a/include/SDL3/begin_code.h
+++ b/include/SDL3/begin_code.h
@@ -172,16 +172,17 @@
#ifndef SDL_MALLOC
#if defined(__GNUC__)
#define SDL_MALLOC __attribute__((malloc))
-// FIXME
-//#elif defined(_MSC_VER)
-//#define SDL_MALLOC __declspec(allocator) __desclspec(restrict)
+/* FIXME
+#elif defined(_MSC_VER)
+#define SDL_MALLOC __declspec(allocator) __desclspec(restrict)
+*/
#else
#define SDL_MALLOC
#endif
#endif /* SDL_MALLOC not defined */
#ifndef SDL_ALLOC_SIZE
-#if defined(__GNUC__)
+#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define SDL_ALLOC_SIZE(p) __attribute__((alloc_size(p)))
#elif defined(_MSC_VER)
#define SDL_ALLOC_SIZE(p)
@@ -191,7 +192,7 @@
#endif /* SDL_ALLOC_SIZE not defined */
#ifndef SDL_ALLOC_SIZE2
-#if defined(__GNUC__)
+#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
#define SDL_ALLOC_SIZE2(p1, p2) __attribute__((alloc_size(p1, p2)))
#elif defined(_MSC_VER)
#define SDL_ALLOC_SIZE2(p1, p2)