From 00783d821dda27ce4e918ab5c1beff794ce73a5b Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Mon, 22 Sep 2025 23:28:11 +0800 Subject: [PATCH] meson/util: Define _GNU_SOURCE for mingw Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13944 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13906 Even though use -Dc_std=gnu18 -Dcpp_std=gnu++20 can also compile with mingw, but for not bothering user, let's us define _GNU_SOURCE for mingw, and it's also expose more functional that exists in mingw As it's not a fixes just a improve so have no fixes in commit message Signed-off-by: Yonggang Luo Tested-by: Vinson Lee Tested-by: Prodea Alexandru-Liviu Part-of: --- meson.build | 3 +++ src/util/u_string.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 08f24f53933..5d6ee648f24 100644 --- a/meson.build +++ b/meson.build @@ -1090,6 +1090,9 @@ elif host_machine.system() == 'windows' '-D_UCRT_NOISY_NAN', # https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907?viewtype=all ] else + # MINGW also accept _GNU_SOURCE + pre_args += '-D_GNU_SOURCE' + # When the target is not (mingw with ucrt) # NOTE: clang's stddef.h are conflict with mingw or ucrt's stddef.h # So do not include headers that defined in clang for detecting diff --git a/src/util/u_string.h b/src/util/u_string.h index 73d5c3be3e4..093101af8a0 100644 --- a/src/util/u_string.h +++ b/src/util/u_string.h @@ -50,7 +50,7 @@ extern "C" { #endif -#if !defined(_GNU_SOURCE) || defined(__APPLE__) +#if !defined(_GNU_SOURCE) || defined(__APPLE__) || defined(DETECT_OS_WINDOWS) #define strchrnul util_strchrnul static inline char *