From 4ce4feac151d6313707b849e51d7be4c1a41d102 Mon Sep 17 00:00:00 2001 From: Biggs McWedge <181115504+TheRealBiggs@users.noreply.github.com> Date: Fri, 28 Aug 2026 16:47:27 +0100 Subject: [PATCH] Fix game startup crash when compiled with MSVC Game projects currently immediately crash upon entering main() due to 0 being passed for `size` when calling `std::setvbuf`. This is allowed by GCC, but MSVC explicitly requires this value to be between 2 and `INT_MAX` (https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setvbuf?view=msvc-170). Changing this 0 to BUFSIZ fixes the crash while retaining compatibility with GCC. --- runtime/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index b7f207da..9fe138a0 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -10625,8 +10625,8 @@ namespace { int main(int argc, char** argv) { /* Force line-buffered output so messages appear even if killed. */ - std::setvbuf(stdout, nullptr, _IOLBF, 0); - std::setvbuf(stderr, nullptr, _IOLBF, 0); + std::setvbuf(stdout, nullptr, _IOLBF, BUFSIZ); + std::setvbuf(stderr, nullptr, _IOLBF, BUFSIZ); std::fprintf(stderr, "psxrecomp: main() entered\n"); std::fflush(stderr); #if defined(RECOMP_LAUNCHER)