Web lists-archives.com

Re: [Mingw-users] mingw error: redefinition of 'struct timespec'

On 11/10/15 10:50, Gisle Vanem wrote:
> G wrote:
>> 1 c:\mingw\include\parts\time.h:65:8: error: redefinition of 'struct timespec'
>> 2 c:\mingw\include\pthread.h:320:8: error: previous definition of 'struct timespec'
>> I have seen that this is an error already referenced in postings on
>> stackoverflow and elsewhere ...

Be careful with advice posted on StackOverflow ... it's often posted by
reputation seekers with absolutely no knowledge or experience of the
actual platform in question, so best treated with grave suspicion.

>> but I don't really know what the solution would be, without making
>> changes in my source code files.

This results from a misfeature of upstream pthreads-win32 -- it makes no
inherent allowance for the possibility that the compiler suite, (on
which it depends), may add its own definition of struct timespec, as we
have done in mingwrt-3.21.1.


Be careful if you adopt this apparently simple "solution"; unless you
also rebuild the pthreads-win32 libraries, with identically the same
addition to CFLAGS, you will have an incompatibility between the
understanding of struct timespec within libpthread.a, (and its
derivatives), ... effectively:

  struct timespec
    __time32_t  tv_sec;
    __int32     tv_nsec;

and the implementation within mingwrt-3.21.1 ... effectively (required
to accommodate the brain damage of MSVCR80.DLL and later):

  struct timespec
    __time64_t tv_sec;
    __int32    tv_nsec;

If you neglect that discrepancy, and your application calls any of the
pthreads-win32 functions which require a struct timespec * parameter,
then your application will exhibit undefined behaviour.

FWIW, I've been exploring various issues within the pthreads-win32
implementation, over the past week or so.  The upstream project conveys
a strong impression of abandonment, so we may wish to adopt and fork it,
but before I do that, and after I've developed a better understanding of
the issues, I will attempt to contact the maintainer of the original
project, and I may then wish to discuss the subject further, here.


Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

Attachment: signature.asc
Description: OpenPGP digital signature

MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe