From 0c19c33bd339827d35b15420f74e37c260e249ea Mon Sep 17 00:00:00 2001 From: Ryan McClelland Date: Thu, 9 Jul 2026 05:44:37 -0700 Subject: [PATCH] libretro: scope Vulkan case to fix MSVC C2360 (#2267) MSVC with /permissive- /WX rejects the switch in retro_load_game: the static vk_negotiation initializer in the Vulkan case is crossed by the next case label (C2360, initialization skipped by case). Wrap the Vulkan case body in a block so its scope ends before that label, and add a comment noting why the braces are required there. The other cases are wrapped in blocks too for visual consistency, though only the Vulkan case strictly needs it. GCC/clang and the MXE cross-build accept the original; this only affects native MSVC builds. No behaviour change. --- src/citra_libretro/citra_libretro.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/citra_libretro/citra_libretro.cpp b/src/citra_libretro/citra_libretro.cpp index c93931196..bb279fef3 100644 --- a/src/citra_libretro/citra_libretro.cpp +++ b/src/citra_libretro/citra_libretro.cpp @@ -552,7 +552,7 @@ bool retro_load_game(const struct retro_game_info* info) { emu_instance->emu_window->UpdateLayout(); switch (Settings::values.graphics_api.GetValue()) { - case Settings::GraphicsAPI::OpenGL: + case Settings::GraphicsAPI::OpenGL: { #ifdef ENABLE_OPENGL LOG_INFO(Frontend, "Using OpenGL hw renderer"); LibRetro::SetHWSharedContext(); @@ -576,7 +576,12 @@ bool retro_load_game(const struct retro_game_info* info) { LibRetro::SetFramebufferCallback(emu_instance->hw_render.get_current_framebuffer); #endif break; - case Settings::GraphicsAPI::Vulkan: + } + case Settings::GraphicsAPI::Vulkan: { + // These braces are required (not only for consistency): vk_negotiation + // below is declared with an initializer, so without an explicit scope + // the following case label would jump past that initialization. MSVC + // rejects that as error C2360 under /permissive- /WX. #ifdef ENABLE_VULKAN LOG_INFO(Frontend, "Using Vulkan hw renderer"); emu_instance->hw_render.context_type = RETRO_HW_CONTEXT_VULKAN; @@ -601,13 +606,15 @@ bool retro_load_game(const struct retro_game_info* info) { LibRetro::SetHWRenderContextNegotiationInterface((void**)&vk_negotiation); #endif break; - case Settings::GraphicsAPI::Software: + } + case Settings::GraphicsAPI::Software: { emu_instance->emu_window->CreateContext(); emu_instance->game_loaded = do_load_game(); if (!emu_instance->game_loaded) return false; break; } + } uint64_t quirks = RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE | RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE;