_POSIX_C_SOURCE-related problems
Ross Johnson
Ross.Johnson@homemail.com.au
Mon Sep 29 22:56:00 GMT 2008
This came up recently and a temporary fix was placed in CVS (sched.h).
Really though, the PTW32_LEVEL stuff needs to be reviewed and appears to
be incorrect, i.e. the line in both sched.h and pthread.h
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
is setting PTW32_LEVEL equal to 1, which is wrong for you (should be 3).
Regards.
Ross
Ramiro Polla wrote:
> Hello,
>
> Simple testcase using MinGW gcc 4.2.4, mingw-runtime 3.15, w32api 3.12:
>
> -----------------------------------------------------------------------
> ramiro@FOUND ~/code/smalls
> $ cat > pthread.c << EOF
> > #include <pthread.h>
> > EOF
>
> ramiro@FOUND ~/code/smalls
> $ gcc -o pthread.o -c pthread.c -D_POSIX_C_SOURCE=200112
> In file included from e:/mingw/include/pthread.h:288,
> from pthread.c:1:
> e:/mingw/include/sched.h:152: error: expected ')' before 'pid'
> e:/mingw/include/sched.h:154: error: expected ')' before 'pid'
> -----------------------------------------------------------------------
>
> This snippet in sched.h (pthreads-w32-2-8-0) starting at line 116
> seems suspicious:
>
> -----------------------------------------------------------------------
> #if defined(__MINGW32__) || defined(_UWIN)
> #if PTW32_LEVEL >= PTW32_LEVEL_MAX
> /* For pid_t */
> # include <sys/types.h>
> /* Required by Unix 98 */
> # include <time.h>
> #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
> #else
> typedef int pid_t;
> #endif
> -----------------------------------------------------------------------
>
> PTW32_LEVEL_MAX is defined to 3 in line 61. PTW32_LEVEL is set to 1
> under this snippet starting at line 49:
>
> -----------------------------------------------------------------------
> #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
> #undef PTW32_LEVEL
> #define PTW32_LEVEL 1
> /* Include 1b, 1c and 1d */
> #endif
> -----------------------------------------------------------------------
>
> I don't understand why sys/types.h isn't included when _POSIX_C_SOURCE
> is defined to 200112. It should be, right? According to [0], pid_t
> must be defined in sys/types.h.
>
> Ramiro Polla
> [0]http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html
>
More information about the Pthreads-win32
mailing list