From 0e63b514d505116766c96a87ac8c5d614fe37cf1 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sat, 7 May 2022 14:52:35 +0200 Subject: [PATCH] Don't define memcpy(), memset() when using static VC runtime. The linker will complain about duplicated symbols otherwise (see #3662, #5156). --- src/stdlib/SDL_stdlib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 9d785aad5..62cbef884 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -549,8 +549,9 @@ int SDL_isblank(int x) { return ((x) == ' ') || ((x) == '\t'); } __declspec(selectany) int _fltused = 1; #endif -/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls */ -#if _MSC_VER >= 1400 +/* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls. + Always provide it for the SDL2 DLL, but skip it when building static lib w/ static runtime. */ +#if (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT)) extern void *memcpy(void* dst, const void* src, size_t len); #pragma intrinsic(memcpy) @@ -570,7 +571,7 @@ memset(void *dst, int c, size_t len) { return SDL_memset(dst, c, len); } -#endif /* _MSC_VER >= 1400 */ +#endif /* (_MSC_VER >= 1400) && (!defined(_MT) || defined(DLL_EXPORT)) */ #ifdef _M_IX86