SDL: Define HAVE_LIBC for the platforms with a C library

From 7ed1f3554d52f12797bff1860c5df52e11a10982 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 17 Feb 2024 11:31:06 -0800
Subject: [PATCH] Define HAVE_LIBC for the platforms with a C library

Allow the Visual Studio project to define HAVE_LIBC=0 to enable building without a C runtime on Windows entirely through Visual Studio project changes.
---
 include/build_config/SDL_build_config_android.h    | 1 +
 include/build_config/SDL_build_config_emscripten.h | 1 +
 include/build_config/SDL_build_config_ios.h        | 1 +
 include/build_config/SDL_build_config_macos.h      | 1 +
 include/build_config/SDL_build_config_windows.h    | 7 +++++--
 include/build_config/SDL_build_config_wingdk.h     | 8 +-------
 include/build_config/SDL_build_config_winrt.h      | 1 +
 include/build_config/SDL_build_config_xbox.h       | 8 +-------
 8 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/include/build_config/SDL_build_config_android.h b/include/build_config/SDL_build_config_android.h
index ad75cc1fbabc..4e688d0d3f41 100644
--- a/include/build_config/SDL_build_config_android.h
+++ b/include/build_config/SDL_build_config_android.h
@@ -52,6 +52,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_DLOPEN 1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
diff --git a/include/build_config/SDL_build_config_emscripten.h b/include/build_config/SDL_build_config_emscripten.h
index 7fb5294ded8d..40876c3952fb 100644
--- a/include/build_config/SDL_build_config_emscripten.h
+++ b/include/build_config/SDL_build_config_emscripten.h
@@ -55,6 +55,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_DLOPEN 1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
diff --git a/include/build_config/SDL_build_config_ios.h b/include/build_config/SDL_build_config_ios.h
index e79ca4ce2058..48da8852997c 100644
--- a/include/build_config/SDL_build_config_ios.h
+++ b/include/build_config/SDL_build_config_ios.h
@@ -44,6 +44,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_DLOPEN 1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
diff --git a/include/build_config/SDL_build_config_macos.h b/include/build_config/SDL_build_config_macos.h
index 66bdb5ea4280..9eb5830cdd8b 100644
--- a/include/build_config/SDL_build_config_macos.h
+++ b/include/build_config/SDL_build_config_macos.h
@@ -49,6 +49,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_DLOPEN 1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
diff --git a/include/build_config/SDL_build_config_windows.h b/include/build_config/SDL_build_config_windows.h
index d2846abc8e9b..52c2df72593b 100644
--- a/include/build_config/SDL_build_config_windows.h
+++ b/include/build_config/SDL_build_config_windows.h
@@ -112,8 +112,11 @@ typedef unsigned int uintptr_t;
 #endif
 
 /* This can be disabled to avoid C runtime dependencies and manifest requirements */
-#define HAVE_LIBC
-#ifdef HAVE_LIBC
+#ifndef HAVE_LIBC
+#define HAVE_LIBC   1
+#endif
+
+#if HAVE_LIBC
 /* Useful headers */
 #define HAVE_CTYPE_H 1
 #define HAVE_FLOAT_H 1
diff --git a/include/build_config/SDL_build_config_wingdk.h b/include/build_config/SDL_build_config_wingdk.h
index 3730221d919f..2f25b597e549 100644
--- a/include/build_config/SDL_build_config_wingdk.h
+++ b/include/build_config/SDL_build_config_wingdk.h
@@ -56,8 +56,6 @@
 # define SDL_DISABLE_AVX 1
 #endif
 
-/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
-#ifdef HAVE_LIBC
 /* Useful headers */
 #define HAVE_CTYPE_H 1
 #define HAVE_FLOAT_H 1
@@ -73,6 +71,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
 #define HAVE_REALLOC 1
@@ -156,11 +155,6 @@
 #define HAVE_TRUNCF 1
 #define HAVE__FSEEKI64 1
 #endif    /* _MSC_VER */
-#else
-#define HAVE_STDARG_H   1
-#define HAVE_STDDEF_H   1
-#define HAVE_STDINT_H   1
-#endif
 
 /* Enable various audio drivers */
 #if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H)
diff --git a/include/build_config/SDL_build_config_winrt.h b/include/build_config/SDL_build_config_winrt.h
index bb014efe93d8..08ec512b0708 100644
--- a/include/build_config/SDL_build_config_winrt.h
+++ b/include/build_config/SDL_build_config_winrt.h
@@ -71,6 +71,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
 #define HAVE_REALLOC 1
diff --git a/include/build_config/SDL_build_config_xbox.h b/include/build_config/SDL_build_config_xbox.h
index aecbd3a1222c..2f0f090fe772 100644
--- a/include/build_config/SDL_build_config_xbox.h
+++ b/include/build_config/SDL_build_config_xbox.h
@@ -56,8 +56,6 @@
 # define SDL_DISABLE_AVX 1
 #endif
 
-/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
-#ifdef HAVE_LIBC
 /* Useful headers */
 #define HAVE_CTYPE_H 1
 #define HAVE_FLOAT_H 1
@@ -73,6 +71,7 @@
 #define HAVE_WCHAR_H 1
 
 /* C library functions */
+#define HAVE_LIBC   1
 #define HAVE_MALLOC 1
 #define HAVE_CALLOC 1
 #define HAVE_REALLOC 1
@@ -156,11 +155,6 @@
 #define HAVE_TRUNCF 1
 #define HAVE__FSEEKI64 1
 #endif    /* _MSC_VER */
-#else
-#define HAVE_STDARG_H   1
-#define HAVE_STDDEF_H   1
-#define HAVE_STDINT_H   1
-#endif
 
 /* Enable various audio drivers */
 #if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H)