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 <luoyonggang@gmail.com>
Tested-by: Vinson Lee <vlee@freedesktop.org>
Tested-by: Prodea Alexandru-Liviu <liviuprodea@yahoo.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37514>
This commit is contained in:
Yonggang Luo 2025-09-22 23:28:11 +08:00 committed by Marge Bot
parent a8470a3c1c
commit 00783d821d
2 changed files with 4 additions and 1 deletions

View file

@ -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 '-D_UCRT_NOISY_NAN', # https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907?viewtype=all
] ]
else else
# MINGW also accept _GNU_SOURCE
pre_args += '-D_GNU_SOURCE'
# When the target is not (mingw with ucrt) # When the target is not (mingw with ucrt)
# NOTE: clang's stddef.h are conflict with mingw or ucrt's stddef.h # 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 # So do not include headers that defined in clang for detecting

View file

@ -50,7 +50,7 @@
extern "C" { extern "C" {
#endif #endif
#if !defined(_GNU_SOURCE) || defined(__APPLE__) #if !defined(_GNU_SOURCE) || defined(__APPLE__) || defined(DETECT_OS_WINDOWS)
#define strchrnul util_strchrnul #define strchrnul util_strchrnul
static inline char * static inline char *