Improve handling of platform-specific build options (#2162)

* Opt into POSIX functions with `_POSIX_C_SOURCE` before any system
  headers are `#include`d
* Allow user to override `make develop`'s `WARNFLAGS` and `CXXFLAGS`
* Use `make develop` on 32-bit Cygwin with sanitizers disabled
* Do not unnecessarily redefine `fseek` and `ftell`
* Disable a false-positive `-Wno-null-dereference` on 32-bit Cygwin

Co-authored-by: ISSOtm <[email protected]>
This commit is contained in:
RangiandISSOtm authored and GitHub committed 2026-09-26 16:31:25 -04:00
1 parent 43bdeb873e
commit b732f59472
23 files changed
+60 -40

No files matched your search

+6 -11
View File
@@ -3,6 +3,12 @@
#ifndef RGBDS_PLATFORM_HPP
#define RGBDS_PLATFORM_HPP
// MingGW and Cygwin may need POSIX functions which are not standard C explicitly enabled
// Make sure to keep this before any system header!
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#endif
// MSVC doesn't have str(n)casecmp, use a suitable replacement
#ifdef _MSC_VER
#include <string.h> // IWYU pragma: export
@@ -55,17 +61,6 @@
#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 may need POSIX functions which are not standard C explicitly enabled
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#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.