romdata: include <errno.h> after ultra64.h (fixes the Linux build on macos)

#88 added <errno.h> 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.
This commit is contained in:
James Dansereau committed 2026-09-30 10:02:08 -04:00
1 parent c415315797
commit 12a814a4e4
1 file changed
+10 -2
+10 -2
View File
@@ -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). <sys/mman.h> is a host header the decomp include path does not
* shadow. */
#include <errno.h>
* shadow. <errno.h> is included further down, after ultra64.h. */
#include <sys/mman.h>
#endif
@@ -52,6 +51,15 @@ extern int snprintf(char *str, size_t maxsize, const char *format, ...);
#include <ultra64.h>
#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 <errno.h>
#endif
#define CART_BASE 0x10000000u
static u8 *rom = NULL; /* heap copy (fallback path) */