When I try to compile this file :
#include <unistd.h>
#include <pthread.h>
int main()
{
return 0;
}
I have the error :
In file included from a.c:2:0:
c:\mingw\include\pthread.h:320:8: error: redefinition of 'struct timespec'
struct timespec {
^
In file included from c:\mingw\include\unistd.h:95:0,
from a.c:1:
c:\mingw\include\parts\time.h:65:8: note: originally defined here
struct timespec
Adding :
#define HAVE_STRUCT_TIMESPEC
after
struct timespec
{
/* Period is sum of tv_sec + tv_nsec; use fundamental integer types
* to avoid 32-bit vs. 64-bit time_t ambiguity.
*/
long long tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
in file "C:\MinGW\include\parts\time.h" correct the problem.
Arrrrrrrrrgh!!!!!!!! Please use the preview facility, and correct your markdown before posting, so I don't have to fix it later.
Anyway, I'm aware of this issue; it is a bug in
pthreads-w32, (which doesn't have a configure script, so just makes arbitrary, and possibly bogus assumptions, without performing any requisite feature checks). Addingin
<parts/time.h>is not a valid solution, (because it would pollute the user namespace). This needs to be fixed inpthreads-w32, a proper solution will require that to support proper build-time configuration, and propagation of that configuration to its installed headers.Do please note, that if you are mixing a stock pre-built
pthreads-w32library along withmingwrt-3.21, there is likely a conflict between thestruct timespecdeclared in<parts/time.h>, and the declaration assumed by the pthread library.Diff:
Diff:
This issue should no longer arise, provided you use our
pthreads-w32-2.10:https://sourceforge.net/projects/mingw/files/MinGW/Base/pthreads-w32/pthreads-w32-2.10-pre-20160821-1/
Last edit: Keith Marshall 2017-04-12