From 26d0e1f9e5e133bda9038051da6de643d6613e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Thu, 26 Sep 2024 04:27:14 +0200 Subject: [PATCH] Fix open_memstream/fmemopen feature detection with GCC >= 14 (#544) GCC 14 has enabled various warnings as errors by default, e.g. -Wimplicit-function-declaration. This causes the current feature detection code for `open_memstream(3)` and `fmemopen(3)` to fail with GCC 14. This commit restores compatibility with GCC 14 in this regard. Note that it may also be beneficial to pass a feature test macro such as -D_POSIX_C_SOURCE. See the feature test macro requirements for open_memstream(3)` and `fmemopen(3)`. --- Makefile.config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.config b/Makefile.config index b7284bbd..1742a328 100644 --- a/Makefile.config +++ b/Makefile.config @@ -91,8 +91,9 @@ DESTDIR ?= # Automatically detect platform-specific flags, instead of using autoconf #CYC_PLATFORM_HAS_MEMSTREAM ?= 1 -CYC_PLATFORM_HAS_MEMSTREAM := $(shell echo "main(){char *buf; int len; open_memstream(&buf, &len);}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0) -CYC_PLATFORM_HAS_FMEMOPEN := $(shell echo "main(){char *buf; fmemopen(&buf, 0, \"r\");}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0) +HASH := \# # Needed for compatibility with GNU Make < 4.3 +CYC_PLATFORM_HAS_MEMSTREAM := $(shell printf "$(HASH)include \n%s\n" "int main(void){char *buf; size_t len; open_memstream(&buf, &len); return 0;}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0) +CYC_PLATFORM_HAS_FMEMOPEN := $(shell printf "$(HASH)include \n%s\n" "int main(void){char *buf; fmemopen(&buf, 0, \"r\"); return 0;}" | $(CC) -xc - >/dev/null 2>/dev/null && echo 1 || echo 0) # code from chibi's makefile to detect platform ifndef PLATFORM