From 12a814a4e4442374583e93dd814ab3e1594f52ed Mon Sep 17 00:00:00 2001 From: James Dansereau <106631954+jkdansereau@users.noreply.github.com> Date: Wed, 30 Sep 2026 10:02:08 -0400 Subject: [PATCH] romdata: include after ultra64.h (fixes the Linux build on macos) #88 added to the POSIX include block, ahead of ultra64.h. glibc defines errno as a macro, (*__errno_location ()), which rewrites the N64 `u8 errno;` fields in PR/os.h (OSContStatus, OSContPad, OSContRamIo) and fails with "field '__errno_location' declared as a function". Include it after ultra64.h/bondtypes.h instead. Nothing in this file reads those struct fields; errno is only read by the mmap failure diagnostic. No change on Windows. --- port/src/romdata.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/port/src/romdata.c b/port/src/romdata.c index 785f2d35..a034fa60 100644 --- a/port/src/romdata.c +++ b/port/src/romdata.c @@ -35,8 +35,7 @@ extern int snprintf(char *str, size_t maxsize, const char *format, ...); #else /* POSIX: mmap the ROM at the fixed cart address (mirrors the VirtualAlloc * path). is a host header the decomp include path does not - * shadow. */ - #include + * shadow. is included further down, after ultra64.h. */ #include #endif @@ -52,6 +51,15 @@ extern int snprintf(char *str, size_t maxsize, const char *format, ...); #include #include "bondtypes.h" +#if !defined(PLATFORM_WINDOWS) +/* Must come after ultra64.h: libc defines `errno` as a macro (glibc: + * `(*__errno_location ())`), which would rewrite the N64 `u8 errno;` + * fields in PR/os.h (OSContStatus, OSContPad, ...) into a function + * declaration and break the build ("field '__errno_location' declared as + * a function"). Only the mmap-failure diagnostic below reads errno. */ + #include +#endif + #define CART_BASE 0x10000000u static u8 *rom = NULL; /* heap copy (fallback path) */