See attached patch. - Kirill Makurin
From 87951029ce19f763ebf28262bf0bb3a48fbed0c2 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Sat, 8 Feb 2025 01:45:40 +0900 Subject: [PATCH] winpthreads: make sure WINPTHREAD_API is correctly defined in pthread_time.h
When building with MSVC, pthread_time.h is included from pthread.h before WINPTHREAD_API macro is defined. This may lead to functions declared in pthread_time.h not being exported from the DLL. Use same logic to define WINPTHREAD_API as in pthread.h. Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- .../winpthreads/include/pthread_time.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/include/pthread_time.h b/mingw-w64-libraries/winpthreads/include/pthread_time.h index eec416844..f0ce1cca4 100644 --- a/mingw-w64-libraries/winpthreads/include/pthread_time.h +++ b/mingw-w64-libraries/winpthreads/include/pthread_time.h @@ -78,10 +78,20 @@ typedef int clockid_t; extern "C" { #endif -/* Make sure we provide default for WINPTHREAD_API, if not defined. */ -#pragma push_macro("WINPTHREAD_API") #ifndef WINPTHREAD_API -#define WINPTHREAD_API +# 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 +# endif #endif /* These should really be dllimport'ed if using winpthread dll */ @@ -92,8 +102,6 @@ WINPTHREAD_API int __cdecl clock_getres(clockid_t clock_id, struct timespec *res WINPTHREAD_API int __cdecl clock_gettime(clockid_t clock_id, struct timespec *tp); WINPTHREAD_API int __cdecl clock_settime(clockid_t clock_id, const struct timespec *tp); -#pragma pop_macro("WINPTHREAD_API") - #ifdef __cplusplus } #endif -- 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