This fixes an issue I mentioned[1] earlier. - Kirill Makurin
[1] https://sourceforge.net/p/mingw-w64/mailman/message/59191979/
From 163bbf4a211b1e1bc84d4888e02ed51b46fae5fb Mon Sep 17 00:00:00 2001 From: Kirill Makurin <[email protected]> Date: Mon, 19 Jan 2026 19:53:09 +0900 Subject: [PATCH 1/2] winpthreads: add new macro WINPTHREADS_STATIC_ASSERT This macro allows portable use of static_assert in winpthreads' source and header files. Signed-off-by: Kirill Makurin <[email protected]> --- .../winpthreads/include/pthread_compat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mingw-w64-libraries/winpthreads/include/pthread_compat.h b/mingw-w64-libraries/winpthreads/include/pthread_compat.h index e0b9cc340..5c723a091 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread_compat.h +++ b/mingw-w64-libraries/winpthreads/include/pthread_compat.h @@ -60,6 +60,16 @@ #ifndef WIN_PTHREADS_PTHREAD_COMPAT_H #define WIN_PTHREADS_PTHREAD_COMPAT_H +#if defined(__cplusplus) && __cplusplus >= 201103L +#define WINPTHREADS_STATIC_ASSERT(expr, msg) static_assert ((expr), msg) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define WINPTHREADS_STATIC_ASSERT(expr, msg) static_assert ((expr), msg) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define WINPTHREADS_STATIC_ASSERT(expr, msg) _Static_assert ((expr), msg) +#else +#define WINPTHREADS_STATIC_ASSERT(expr, msg) extern int winpthreads_static_assert[((expr) ? 1 : -1)] +#endif + #if defined(_USE_32BIT_TIME_T) #define WINPTHREADS_TIME_BITS 32 #else -- 2.51.0.windows.1
From 62d6aca1a4ed31bff0500f91fb7b94666b9773af Mon Sep 17 00:00:00 2001 From: Kirill Makurin <[email protected]> Date: Mon, 19 Jan 2026 19:57:11 +0900 Subject: [PATCH 2/2] winpthreads: check if pid_t is defined as macro on MSVC If package that includes winpthreads' header files is using autoconf and calls AC_TYPE_PID_T, the check for pid_t will fail and it will define pid_t as a macro in config.h. Later, when winpthreads' header files are included, this result in compilation error. AC_TYPE_PID_T defines pid_t to the same base type as winpthreads' header files, so we can simply undefine it. Signed-off-by: Kirill Makurin <[email protected]> --- .../winpthreads/include/pthread_compat.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mingw-w64-libraries/winpthreads/include/pthread_compat.h b/mingw-w64-libraries/winpthreads/include/pthread_compat.h index 5c723a091..2124aaa5c 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread_compat.h +++ b/mingw-w64-libraries/winpthreads/include/pthread_compat.h @@ -114,9 +114,24 @@ typedef unsigned short mode_t; #elif _MSC_VER +/** + * If package which includes this header file is using autoconf and calls + * AC_TYPE_PID_T macro, the check for pid_t will fail and it will define pid_t + * as a macro in config.h - this eventually results in compilation error. + * + * Luckily, it defines it to the same base type, so we can simply undefine it. + */ #ifdef _WIN64 +#ifdef pid_t +WINPTHREADS_STATIC_ASSERT (sizeof (pid_t) == sizeof(__int64), "pid_t is defined as a macro with mismatching base type"); +#undef pid_t +#endif typedef __int64 pid_t; #else +#ifdef pid_t +WINPTHREADS_STATIC_ASSERT (sizeof (pid_t) == sizeof(int), "pid_t is defined as a macro with mismatching base type"); +#undef pid_t +#endif typedef int pid_t; #endif -- 2.51.0.windows.1
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
