* _POSIX_C_SOURCE-related problems
@ 2008-09-29 17:59 Ramiro Polla
2008-09-29 22:56 ` Ross Johnson
0 siblings, 1 reply; 3+ messages in thread
From: Ramiro Polla @ 2008-09-29 17:59 UTC (permalink / raw)
To: pthreads-win32
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: _POSIX_C_SOURCE-related problems
2008-09-29 17:59 _POSIX_C_SOURCE-related problems Ramiro Polla
@ 2008-09-29 22:56 ` Ross Johnson
2008-09-30 0:10 ` Ramiro Polla
0 siblings, 1 reply; 3+ messages in thread
From: Ross Johnson @ 2008-09-29 22:56 UTC (permalink / raw)
To: Ramiro Polla; +Cc: pthreads-win32
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: _POSIX_C_SOURCE-related problems
2008-09-29 22:56 ` Ross Johnson
@ 2008-09-30 0:10 ` Ramiro Polla
0 siblings, 0 replies; 3+ messages in thread
From: Ramiro Polla @ 2008-09-30 0:10 UTC (permalink / raw)
To: pthreads-win32
Hello,
On Mon, Sep 29, 2008 at 7:55 PM, Ross Johnson
<Ross.Johnson@homemail.com.au> wrote:
> This came up recently and a temporary fix was placed in CVS (sched.h).
Hmm... I wonder how I missed that thread [0].
> 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).
Thanks,
Ramiro Polla
[0] http://sourceware.org/ml/pthreads-win32/2008/msg00045.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-30 0:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-29 17:59 _POSIX_C_SOURCE-related problems Ramiro Polla
2008-09-29 22:56 ` Ross Johnson
2008-09-30 0:10 ` Ramiro Polla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).