From 8b0660b25acd1ce0a5f763fffb3d9e6f0cd8de8f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 30 Dec 2019 13:18:57 -0800 Subject: [PATCH] Fixed bug 4918 - SDL failed to build due to error LNK2019: unresolved external symbol memset referenced in function SDL_SetJoystickIDForPlayerIndex with MSVC x64 on Windows LinGao We build SDL with Visual studio 2017 compiler on Windows Server 2016, but it failed to build due to error LNK2019: unresolved external symbol memset referenced in function SDL_SetJoystickIDForPlayerIndex with MSVC x64 on Windows on latest default branch. And we found that it can be first reproduced on 0fff06175109 changeset. Could you please help have a look about this issue? Thanks in advance! Steps to Reproduce: 1.hg clone https://hg.libsdl.org/SDL D:\SDL\src 2.Open a VS 2017 x64 command prompt as admin and browse to D:\SDL 3.msbuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17134.0 VisualC\SDL.sln /t:Rebuild Actual result: Creating library D:\SDL\src\VisualC\x64\Release\SDL2.lib and object D:\SDL\src\VisualC\x64\Release\SDL2.exp SDL_joystick.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_SetJoystickIDForPlayerIndex [D:\SDL\src\VisualC\SDL\SDL.vcxproj] D:\SDL\src\VisualC\x64\Release\SDL2.dll : fatal error LNK1120: 1 unresolved externals [D:\SDL\src\VisualC\SDL\SDL.vcxproj] Done Building Project "D:\SDL\src\VisualC\SDL\SDL.vcxproj" (Rebuild target(s)) -- FAILED. --- src/joystick/SDL_joystick.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 56d8fe2d6..93772ec8a 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -158,9 +158,8 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) } SDL_joystick_players = new_players; - while (SDL_joystick_player_count <= player_index) { - SDL_joystick_players[SDL_joystick_player_count++] = -1; - } + SDL_memset(&SDL_joystick_players[SDL_joystick_player_count], 0xFF, (player_index - SDL_joystick_player_count + 1) * sizeof(SDL_joystick_players[0])); + SDL_joystick_player_count = player_index + 1; } SDL_joystick_players[player_index] = instance_id;