Fixed bug 5112 - CMake won't compile in VS2019

dark_sylinc

Trying to build SDL with VS2019 using CMake will encounter a linking error

More specifically:

    1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
Sam Lantinga 2020-05-02 14:43:17 -07:00
parent 05a60c2ea3
commit 8b60d39cb0
1 changed files with 13 additions and 33 deletions

View File

@ -486,42 +486,22 @@ int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) :
__declspec(selectany) int _fltused = 1; __declspec(selectany) int _fltused = 1;
#endif #endif
/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */ /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls */
#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT)) #if _MSC_VER >= 1400
#include <intrin.h>
#pragma function(memcpy) #pragma function(memcpy)
void * memcpy ( void * destination, const void * source, size_t num ) void *
memcpy(void *dst, const void *src, size_t len)
{ {
const Uint8 *src = (const Uint8 *)source; return SDL_memcpy(dst, src, len);
Uint8 *dst = (Uint8 *)destination;
size_t i;
/* All WIN64 architectures have SSE, right? */
if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
__m128 values[4];
for (i = num / 64; i--;) {
_mm_prefetch(src, _MM_HINT_NTA);
values[0] = *(__m128 *) (src + 0);
values[1] = *(__m128 *) (src + 16);
values[2] = *(__m128 *) (src + 32);
values[3] = *(__m128 *) (src + 48);
_mm_stream_ps((float *) (dst + 0), values[0]);
_mm_stream_ps((float *) (dst + 16), values[1]);
_mm_stream_ps((float *) (dst + 32), values[2]);
_mm_stream_ps((float *) (dst + 48), values[3]);
src += 64;
dst += 64;
}
num &= 63;
}
while (num--) {
*dst++ = *src++;
}
return destination;
} }
#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
#pragma function(memset)
void *
memset(void *dst, int c, size_t len)
{
return SDL_memset(dst, c, len);
}
#endif
#ifdef _M_IX86 #ifdef _M_IX86