mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-20 13:54:33 +00:00
Use _fseeki64/_ftelli64 on Windows since fseek/fell are limited by 32-bit long
This commit is contained in:
@@ -55,6 +55,12 @@
|
||||
#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__)
|
||||
#define fseek _fseeki64
|
||||
#define ftell _ftelli64
|
||||
#endif
|
||||
|
||||
// MingGW and Cygwin need POSIX functions which are not standard C explicitly enabled,
|
||||
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@
|
||||
#include "helpers.hpp"
|
||||
#include "itertools.hpp" // InsertionOrderedMap
|
||||
#include "linkdefs.hpp"
|
||||
#include "util.hpp" // xfclose, seekSize
|
||||
#include "platform.hpp" // fseek
|
||||
#include "util.hpp" // xfclose, seekSize
|
||||
|
||||
#include "asm/fstack.hpp"
|
||||
#include "asm/lexer.hpp"
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ std::optional<uint64_t> seekSize(FILE *file) {
|
||||
if (fseek(file, 0, SEEK_END) != 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
long size = ftell(file);
|
||||
auto size = ftell(file); // Use `auto` since Windows' `_ftelli64` returns `__int64`, not `long`
|
||||
if (size < 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user