See commit message. I have a question. What do you think about adding .pc (pkg-config) file for winpthreads?
There is also a problematic interaction between pthread_compat.h and autoconf's AC_TYPE_PID_T. With MSVC, this check will fail and it will ``` #define pid_t ... ``` If pthread_compat.h is later included, this results in syntax error in ``` #ifdef _WIN64 typedef __int64 pid_t; #else typedef int pid_t; #endif ``` We could guard typedef with `#ifndef pid_t`, or add the following just above: ``` #ifdef pid_t #undef pid_t #endif ``` - Kirill Makurin
From 8c131c07c784799b56a889b0c25396e0c0ddb9e8 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Fri, 6 Jun 2025 18:26:24 +0900 Subject: [PATCH] winpthreads: do not expose IN_WINPTHREAD in public header files When building winpthreads, define WINPTHREAD_API in config.h instead of public pthread_compat.h. Definition of WINPTHREAD_API in pthread_compat.h will only be used by client code. Note that IN_WINPTHREAD is still defined. It is checked for in mingw-w64's time.h. Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/configure.ac | 9 +++++++++ .../winpthreads/include/pthread_compat.h | 18 ++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/configure.ac b/mingw-w64-libraries/winpthreads/configure.ac index 45d382136..f29d3c27b 100644 --- a/mingw-w64-libraries/winpthreads/configure.ac +++ b/mingw-w64-libraries/winpthreads/configure.ac @@ -54,5 +54,14 @@ LT_LANG([Windows Resource]) # Checks for library functions. +# config.h +AH_BOTTOM( +[#ifdef DLL_EXPORT +#define WINPTHREAD_API __declspec(dllexport) +#else +#define WINPTHREAD_API +#endif]dnl +) + AC_CONFIG_FILES([Makefile tests/Makefile]) AC_OUTPUT diff --git a/mingw-w64-libraries/winpthreads/include/pthread_compat.h b/mingw-w64-libraries/winpthreads/include/pthread_compat.h index 3a8552882..b682a3a17 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread_compat.h +++ b/mingw-w64-libraries/winpthreads/include/pthread_compat.h @@ -66,18 +66,12 @@ #define WINPTHREADS_TIME_BITS 64 #endif -#if defined(IN_WINPTHREAD) -# if defined(DLL_EXPORT) -# define WINPTHREAD_API __declspec(dllexport) /* building the DLL */ -# else -# define WINPTHREAD_API /* building the static library */ -# endif -#else -# if defined(WINPTHREADS_USE_DLLIMPORT) -# define WINPTHREAD_API __declspec(dllimport) /* user wants explicit `dllimport` */ -# else -# define WINPTHREAD_API /* the default; auto imported in case of DLL */ -# endif +#ifndef WINPTHREAD_API +# ifdef WINPTHREADS_USE_DLLIMPORT +# define WINPTHREAD_API __declspec(dllimport) +# else +# define WINPTHREAD_API +# endif #endif #ifndef __clockid_t_defined -- 2.46.1.windows.1
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public