I'm getting a compilation failure when trying to cross-compile from Linux to mingw, because I have the mingw pthreads-win32 (ptw32) library installed (Fedora 13 system, with mingw32-pthreads and mingw32-gcc packages). The ptw32 library installs a pthread.h that blindly defines struct timespec if HAVE_STRUCT_TIMESPEC is not defined:
#ifndef HAVE_STRUCT_TIMESPEC #define HAVE_STRUCT_TIMESPEC 1 struct timespec { long tv_sec; long tv_nsec; }; #endif /* HAVE_STRUCT_TIMESPEC */ That library also has the nasty behavior of installing a config.h file, which it then includes as part of pthread.h (recommended practice is that config.h must NEVER be installed, and that if you are installing a public header that depends on configuration options, you should install a header by a different name that only your package will refer to, and that you should make an extreme effort to make the file be independent of compiler options that might differ between when your library was configured vs. when a client of your library is configured). Meanwhile, the gnulib library provides a replacement struct timespec, and correctly declares it in the time.h header: * Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in <sys/time.h> (e.g., FreeBSD circa 1997). */ # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ # include <sys/time.h> # else # ifdef __cplusplus extern "C" { # endif # undef timespec # define timespec rpl_timespec struct timespec { time_t tv_sec; long int tv_nsec; }; Unfortunately, the gnulib replacement conflicts with the ptw32 version: make all-am make[1]: Entering directory `/home/remote/eblake/libvirt-tmp/build/src' CC libvirt_util_la-hooks.lo In file included from ../../src/util/threads-pthread.h:24, from ../../src/util/threads.h:65, from ../../src/conf/domain_conf.h:36, from ../../src/util/hooks.c:36: /usr/i686-pc-mingw32/sys-root/mingw/include/pthread.h:307: error: redefinition of 'struct rpl_timespec' make[1]: *** [libvirt_util_la-hooks.lo] Error 1 make[1]: Leaving directory `/home/remote/eblake/libvirt-tmp/build/src' make: *** [all] Error 2 I'm not sure of the best fix for this. A naive fix would be having gnulib #define HAVE_STRUCT_TIMESPEC in its replacement time.h if it defined the replacement, but I'm not sure if that is safe for all possible inclusion orders of <pthread.h> and/or <time.h> within various source files. Maybe gnulib's m4/time_h.m4 needs to check whether <pthread.h> exists and defines struct timespec, and not override struct timespec in that case? -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature