Browse Source

Workaround for Visual Studio 2019 const warning

Visual Studio 2022, gcc, and clang all agree that "const SDL_DisplayMode **" is a non-const pointer to const data, but Visual Studio 2019 warns about this, so we'll just add a cast to the SDL_free() call for now.

Apparently this was a legitimate bug that has been recently fixed:
https://stackoverflow.com/questions/10403713/why-does-visual-c-warn-on-implicit-cast-from-const-void-to-void-in-c-but
Sam Lantinga 2 years ago
parent
commit
9ff1055489
4 changed files with 6 additions and 6 deletions
  1. 1 1
      src/test/SDL_test_common.c
  2. 2 2
      src/video/SDL_video.c
  3. 1 1
      test/testautomation_video.c
  4. 2 2
      test/testwm.c

+ 1 - 1
src/test/SDL_test_common.c

@@ -1162,7 +1162,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
                         }
                     }
                 }
-                SDL_free(modes);
+                SDL_free((void *)modes);
 
 #if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
                 /* Print the D3D9 adapter index */

+ 2 - 2
src/video/SDL_video.c

@@ -913,7 +913,7 @@ static const SDL_DisplayMode *SDL_GetFullscreenModeMatch(const SDL_DisplayMode *
             }
         }
 
-        SDL_free(modes);
+        SDL_free((void *)modes);
     }
     return mode;
 }
@@ -1068,7 +1068,7 @@ const SDL_DisplayMode *SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID display
 
             closest = mode;
         }
-        SDL_free(modes);
+        SDL_free((void *)modes);
     }
     return closest;
 }

+ 1 - 1
test/testautomation_video.c

@@ -359,7 +359,7 @@ int video_getFullscreenDisplayModes(void *arg)
             SDLTest_AssertPass("Call to SDL_GetFullscreenDisplayModes(%" SDL_PRIu32 ")", displays[i]);
             SDLTest_AssertCheck(modes != NULL, "Validate returned value from function; expected != NULL; got: %p", modes);
             SDLTest_AssertCheck(count >= 0, "Validate number of modes; expected: >= 0; got: %d", count);
-            SDL_free(modes);
+            SDL_free((void *)modes);
         }
         SDL_free(displays);
     }

+ 2 - 2
test/testwm.c

@@ -138,7 +138,7 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_FRect viewport)
             column_chars = 0;
         }
     }
-    SDL_free(modes);
+    SDL_free((void *)modes);
 }
 
 void loop()
@@ -212,7 +212,7 @@ void loop()
                     SDL_memcpy(&state->fullscreen_mode, modes[highlighted_mode], sizeof(state->fullscreen_mode));
                     SDL_SetWindowFullscreenMode(window, modes[highlighted_mode]);
                 }
-                SDL_free(modes);
+                SDL_free((void *)modes);
             }
         }
     }