diff --git a/port/include/pc_protos.h b/port/include/pc_protos.h index 836819f9..6d4096e8 100644 --- a/port/include/pc_protos.h +++ b/port/include/pc_protos.h @@ -201,6 +201,11 @@ void fileUpdateSelectedBondInSave(); s32 fogGetPropDistColor(); void fogLoadLevelEnvironment(); void free(); +/* D38: the N64 stub declares neither, and unlike MinGW a strict + * host GCC does not leak them — so getenv()'s 64-bit pointer return is + * truncated to int (crashed configGetFrameDump on Linux). */ +char * getenv(); +void * realloc(); int frontGetPlayersFavoriteWeaponInHand(); void generate_player_thrown_grenade(); void generate_player_thrown_knife(); diff --git a/port/shim/stdlib.h b/port/shim/stdlib.h index 868956c1..5512a05f 100644 --- a/port/shim/stdlib.h +++ b/port/shim/stdlib.h @@ -17,4 +17,15 @@ #include "hoststdlib.h" #else #include "include/stdlib.h" +#if !defined(_WIN32) +/* The N64 stub declares only lldiv_t/ldiv_t + lldiv/ldiv. MinGW's other CRT + * headers leak getenv() etc.; a strict host GCC (Linux/macOS) does not, so + * getenv()'s 64-bit pointer return is assumed int and truncated (crashed + * configGetFrameDump). Declare the pointer-returning stragglers the port + + * game code use that nothing else declares. K&R form = compatible with any + * real prototype. (malloc/calloc/free are in port/include/pc_protos.h and + * a few port TUs' own local decls — not repeated here to avoid conflicts.) */ +extern char *getenv(); +extern void *realloc(); +#endif #endif