Daiki Ueno wrote: > This actually seems like an issue in Gnulib: > > ``` > $ git clone --depth=1 https://git.savannah.gnu.org/git/gnulib.git > $ cd gnulib > $ ./gnulib-tool --create-testdir --dir t pthread-h pthread-h-c++-tests > $ mingw64-configure > $ make > [...] > x86_64-w64-mingw32-g++ -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 > -DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib -I./../gllib -Wno-error > -Wno-error -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions > --param=ssp-buffer-size=4 -MT test-pthread-c++.o -MD -MP -MF > .deps/test-pthread-c++.Tpo -c -o test-pthread-c++.o test-pthread-c++.cc > In file included from test-pthread-c++.cc:22: > ../gllib/pthread.h:2542:25: error: 'pthread_create' has not been declared in > 'gnulib' > 2542 | using GNULIB_NAMESPACE::pthread_create; > | ^~~~~~~~~~~~~~ > ```
This patch fixes it. Thanks for the report. 2026-05-06 Bruno Haible <[email protected]> pthread-h: Fix compilation error in C++ mode. Reported by Daiki Ueno. * lib/pthread.in.h: Disable the 'using GNULIB_NAMESPACE::pthread_*' directives for which the corresponding Gnulib module is not present. diff --git a/lib/pthread.in.h b/lib/pthread.in.h index 37deab8247..54eb83b015 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -1949,30 +1949,44 @@ _GL_WARN_ON_USE (pthread_spin_destroy, "pthread_spin_destroy is not portable - " #if defined __cplusplus && defined GNULIB_NAMESPACE && !@HAVE_PTHREAD_H@ && defined __MINGW32__ /* Provide the symbols required by mingw's <bits/gthr-default.h>. */ +# if @GNULIB_PTHREAD_THREAD@ using GNULIB_NAMESPACE::pthread_create; using GNULIB_NAMESPACE::pthread_self; using GNULIB_NAMESPACE::pthread_equal; using GNULIB_NAMESPACE::pthread_detach; using GNULIB_NAMESPACE::pthread_join; +# endif +# if @GNULIB_PTHREAD_ONCE@ using GNULIB_NAMESPACE::pthread_once; +# endif +# if @GNULIB_PTHREAD_MUTEX@ using GNULIB_NAMESPACE::pthread_mutex_init; using GNULIB_NAMESPACE::pthread_mutexattr_init; using GNULIB_NAMESPACE::pthread_mutexattr_settype; using GNULIB_NAMESPACE::pthread_mutexattr_destroy; using GNULIB_NAMESPACE::pthread_mutex_lock; using GNULIB_NAMESPACE::pthread_mutex_trylock; +# endif +# if @GNULIB_PTHREAD_MUTEX_TIMEDLOCK@ using GNULIB_NAMESPACE::pthread_mutex_timedlock; +# endif +# if @GNULIB_PTHREAD_MUTEX@ using GNULIB_NAMESPACE::pthread_mutex_unlock; using GNULIB_NAMESPACE::pthread_mutex_destroy; +# endif +# if @GNULIB_PTHREAD_COND@ using GNULIB_NAMESPACE::pthread_cond_wait; using GNULIB_NAMESPACE::pthread_cond_timedwait; using GNULIB_NAMESPACE::pthread_cond_signal; using GNULIB_NAMESPACE::pthread_cond_broadcast; using GNULIB_NAMESPACE::pthread_cond_destroy; +# endif +# if @GNULIB_PTHREAD_TSS@ using GNULIB_NAMESPACE::pthread_key_create; using GNULIB_NAMESPACE::pthread_setspecific; using GNULIB_NAMESPACE::pthread_getspecific; using GNULIB_NAMESPACE::pthread_key_delete; +# endif #endif
