Bug 284

Summary: POSIX.1-2001: code not compiling when -D_XOPEN_SOURCE=600 only defined
Product: glibc Reporter: Andrew Josey <a.josey>
Component: libcAssignee: GOTO Masanori <gotom>
Status: RESOLVED WORKSFORME    
Severity: normal CC: glibc-bugs
Priority: P2 Flags: fweimer: security-
Version: 2.3.3   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:
Bug Depends on:    
Bug Blocks: 724    
Attachments: Test program

Description Andrew Josey 2004-07-23 16:28:39 UTC
The attached code does not compile when compiled with just
c99 -c -D_XOPEN_SOURCE=600
but does when you add -D_POSIX_C_SOURCE=200112L,
i.e. 

 $ c99 -c  -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L ts.c
-sh-2.05b$ c99 -c  -D_XOPEN_SOURCE=600  ts.c
In file included from ts.c:2:
/usr/include/pthread.h:651: error: syntax error before "clockid_t"
ts.c:28: error: syntax error before "siginfo_t"
ts.c: In function `dummy_rt_signal':
ts.c:36: error: structure has no member named `sa_sigaction'

POSIX 1003.1 volume System Interfaces Section 2.2.1 states:

Since this volume of IEEE Std 1003.1-2001 is aligned with the ISO C standard,
and since all functionality enabled by _POSIX_C_SOURCE set equal to 200112L is
enabled by _XOPEN_SOURCE set equal to 600, there should be no need to define
_POSIX_C_SOURCE if _XOPEN_SOURCE is so defined. Therefore, if _XOPEN_SOURCE is
set equal to 600 and _POSIX_C_SOURCE is set equal to 200112L, the behavior is
the same as if only _XOPEN_SOURCE is defined and set equal to 600. However,
should _POSIX_C_SOURCE be set to a value greater than 200112L, the behavior is
unspecified
Comment 1 Andrew Josey 2004-07-23 16:30:59 UTC
Created attachment 141 [details]
Test program
Comment 2 GOTO Masanori 2004-07-24 16:44:06 UTC
Hi,
Andrew, I checked your program and it can be compiled with the latest cvs.
Comment 3 Sourceware Commits 2005-02-17 01:11:15 UTC
Subject: Bug 284

CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	roland@sources.redhat.com	2005-02-17 01:11:00

Modified files:
	include        : features.h 

Log message:
	2004-07-23  Jakub Jelinek  <jakub@redhat.com>
	
	[BZ #284]
	* include/features.h (_POSIX_SOURCE, _POSIX_C_SOURCE): Define
	if _XOPEN_SOURCE >= 500 even if __STRICT_ANSI__ is defined.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/include/features.h.diff?cvsroot=glibc&r1=1.37&r2=1.38

Comment 4 Sourceware Commits 2005-02-18 00:09:12 UTC
Subject: Bug 284

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_3-branch
Changes by:	roland@sources.redhat.com	2005-02-18 00:08:58

Modified files:
	include        : features.h 

Log message:
	2004-07-23  Jakub Jelinek  <jakub@redhat.com>
	
	[BZ #284]
	* include/features.h (_POSIX_SOURCE, _POSIX_C_SOURCE): Define
	if _XOPEN_SOURCE >= 500 even if __STRICT_ANSI__ is defined.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/include/features.h.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.36&r2=1.36.2.1