0

I am trying to compile multiple thirdparty library gist and pthread on windows10 using mingw32_make. However, i am getting redefinition error coming from line "#define PTW32_LEVEL 1".

Q1) Is it that the "#undef PTW32_LEVEL" didn't work at all? That doesn't sound right.

I have already looked at this and this "PTW32_LEVEL" isn't predefined by compiler as defined here.

Q2) what am i missing here? possible workarounds?

#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL
#define PTW32_LEVEL 1
/* Include 1b, 1c and 1d */
#endif

There are other redefinitions as well but the summary is same. Error screenshot and header file with #define and #undef Error:

make
gcc -c -Wall -O3 -g gist.c -ID:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include -DUSE_GIST -DSTANDALONE_GIST
In file included from gist.c:15:0:
D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/pthread.h:108:0: warning: "PTW32_LEVEL" redefined
 #define PTW32_LEVEL PTW32_LEVEL_MAX

D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/pthread.h:95:0: note: this is the location of the previous definition
 #define PTW32_LEVEL 1

In file included from D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/pthread.h:299:0,
                 from gist.c:15:
D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/sched.h:64:0: warning: "PTW32_SCHED_LEVEL" redefined
 #define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX

D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/sched.h:51:0: note: this is the location of the previous definition
 #define PTW32_SCHED_LEVEL 1

In file included from gist.c:15:0:
D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/pthread.h:320:8: error: redefinition of 'struct timespec'
 struct timespec {
        ^~~~~~~~
In file included from D:\prjs\im-similarity\repo\pthreads-w32-2-9-1-release\Pre-built.2\include/pthread.h:219:0,
                 from gist.c:15:
c:\mingw\include\time.h:115:8: note: originally defined here
 struct timespec
        ^~~~~~~~
Makefile:17: recipe for target 'gist.o' failed
make: *** [gist.o] Error 1

Header:

#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL
#define PTW32_LEVEL 1
/* Include 1b, 1c and 1d */
#endif

#if defined(INCLUDE_NP)
#undef PTW32_LEVEL
#define PTW32_LEVEL 2
/* Include Non-Portable extensions */
#endif

#define PTW32_LEVEL_MAX 3

#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 )  || !defined(PTW32_LEVEL)
#define PTW32_LEVEL PTW32_LEVEL_MAX
/* Include everything */
#endif
1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Aparajuli
  • 344
  • 1
  • 2
  • 15
  • You should be able to test just those 4 lines. – stark Jul 12 '21 at 22:56
  • 1
    The errors and header extract should be posted _as text_, not images, in part because images aren't searchable. But it appears that the header is buggy. With the first error, if `_POSIX_C_SOURCE` is defined to have a value of `200112` or larger it will define `PTW32_LEVEL` on line 95 then redefine it on line 108. It needs a `#undef PTW32_LEVEL` between lines 107 and 108. – 1201ProgramAlarm Jul 13 '21 at 03:22

0 Answers0