Page MenuHome GnuPG

struct timespec is already defined in MINGW32
Closed, ResolvedPublic

Description

line 52 of w32/npth.h may be better:
#if (MINGW64_VERSION_MAJOR < 2) && (MINGW32__ != 1)
instead of just checking for __MINGW64_VERSION_MAJOR < 2.

struct timespec is already defined here.

gcc --version:
4.8.1

$ gcc -dM -E - < /dev/null | grep -i mingw:
#define MINGW32 1

time.h,v 43b5fbe8586e 2014/12/23 20:59:37

error log:

In file included from call-gpg.c:25:0:
C:/MinGW/msys/1.0/home/x/w32root/include/npth.h:53:8: error: redefinition of 's
truct timespec'
struct timespec {

^

In file included from c:\mingw\include\unistd.h:95:0,

from C:/MinGW/msys/1.0/home/x/w32root/include/assuan.h:28,
from call-gpg.c:23:

c:\mingw\include\parts\time.h:65:8: note: originally defined here
struct timespec

^

make[3]: * [libcommon_a-call-gpg.o] Error 1
make[3]: Leaving directory `/c/d/gnupg-2.1.10.tar/gnupg-2.1.10/common'
make[2]:
* [all] Error 2
make[2]: Leaving directory `/c/d/gnupg-2.1.10.tar/gnupg-2.1.10/common'
make[1]: * [all-recursive] Error 1
make[1]: Leaving directory `/c/d/gnupg-2.1.10.tar/gnupg-2.1.10'
make:
* [all] Error 2

Details

Version
1.2

Revisions and Commits

Event Timeline

gniibe added a subscriber: gniibe.

I confirmed that mingw-w64 version 1.0 defines timespec.
So, for older versions of mingw-w64, we need a fix to avoid errors.
But, your suggestion of __MINGW32__ != 1 seems wrong to me (I think it is always defined as 1).

I change the #if..#endif to #ifndef..#endif with MINGW64_VERSION_MAJOR, examining how other projects do. I checked vlc, libcdio, and Pthreads-win32.
The commit is: rPTH217bc1c6aaba: w32: Change the condition for struct timespec..

Fixed in npth 1.4.