From 7b7bb57bcbd6a75432d27812ce8b078b7c98947a Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Mon, 28 Sep 2026 23:36:02 -0400 Subject: [PATCH] Restore usage of `_fseeki64` and `_ftelli64` on Windows (#2185) These overrides were removed in b732f5947220ff2efcd19cebeb2aa9312af0c861, but that broke handling of >2GiB files for `seekSize`. --- include/platform.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/platform.hpp b/include/platform.hpp index bbee456e..d899ae06 100644 --- a/include/platform.hpp +++ b/include/platform.hpp @@ -67,6 +67,13 @@ #define setmode(fd, mode) (0) #endif +// Windows has 32-bit `long`, which limits `fseek` and `ftell` to 2 GiB +#if defined(_MSC_VER) || defined(__MINGW32__) + #include // IWYU pragma: export + #define fseek _fseeki64 + #define ftell _ftelli64 +#endif + // Apple has deprecated `sprintf` since Xcode 14 (for macOS 13), but we use it solely in // contexts where both the size of the buffer *and* max size of the printed string are // known statically, which GCC thus checks for.