From fbfcca3277a5f13dd78f7d44ffe2dc65d4e2d048 Mon Sep 17 00:00:00 2001
From: Carlo Bramini <[EMAIL REDACTED]>
Date: Thu, 26 Aug 2021 12:36:54 +0200
Subject: [PATCH] [WINCE] strdup() is not supported under _WIN32_WCE
When compiling with Embedded Visual Studio, strdup() is not supported.
If HAVE_STRDUP is left declared as it is, first the C compiler prints a warning because the function is undeclared, then the linker prints an error because strdup() has not been found. The solution is to disable HAVE_STRDUP if _WIN32_WCE is detected or leave the user the control on that macro but define strdup() to _strdup(), which is better in terms of memory usage since it is taken from corelibc.
---
include/SDL_config_win32.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/SDL_config_win32.h b/include/SDL_config_win32.h
index 6d2ae2d67..93cf61f44 100644
--- a/include/SDL_config_win32.h
+++ b/include/SDL_config_win32.h
@@ -131,6 +131,12 @@ typedef unsigned int uintptr_t;
#define HAVE_STDDEF_H 1
#endif
+/* Windows CE can support only _strdup() */
+#if defined(_WIN32_WCE) && defined(HAVE_STRDUP)
+#undef strdup
+#define strdup _strdup
+#endif
+
/* Enable various audio drivers */
#ifndef _WIN32_WCE
#define SDL_AUDIO_DRIVER_DSOUND 1