Now that winpthreads can be built with MSVC, I think it is usable as a package
on its own. Having a pkg-config file would make using winpthreads much easier
with meson and cmake.
For instance, with meson one could
```
If host_machine.system() == 'windows'
threads = dependency('winpthreads')
else
threads = dependency('threads')
endif
```
to use POSIX threads with both mingw-w64 and msvc.
So far, the only project that comes to mind to use this is glib. I think it
allows to force usage of POSIX threads.
- Kirill Makurin
________________________________
From: LIU Hao
Sent: Wednesday, June 11, 2025 11:58 PM
To: [email protected]; Kirill Makurin
Subject: Re: [Mingw-w64-public] winpthreads: do not expose IN_WINPTHREAD in
public header files
在 2025-6-6 17:41, Kirill Makurin 写道:
> From 8c131c07c784799b56a889b0c25396e0c0ddb9e8 Mon Sep 17 00:00:00 2001
> From: Kirill Makurin <[email protected]>
> 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 <[email protected]>
> ---
> mingw-w64-libraries/winpthreads/configure.ac | 9 +++++++++
> .../winpthreads/include/pthread_compat.h | 18 ++++++------------
> 2 files changed, 15 insertions(+), 12 deletions(-)
The patch looks good to me. I have pushed it to master now.
I am actually in favor of this solution. I have another very similar setup with
Meson, with this
definition in pre-compiled header instead.
> I have a question. What do you think about adding .pc (pkg-config) file for
> winpthreads?
If winpthreads is linked as `-pthread` (standard? no?) then there's no need to
do that, because nobody
would use pkgconf to look 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
It is an unfortunate mistake. If VC defines `pid_t` then the VC definition
should be preferred.
--
Best regards,
LIU Hao
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public