Subject: bin/4885: unistd.h doesn't test for _XOPEN_SOURCE
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ian.dall@dsto.defence.gov.au>
List: netbsd-bugs
Date: 01/26/1998 00:02:04
>Number:         4885
>Category:       bin
>Synopsis:       unistd.h doesn't test for _XOPEN_SOURCE
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 25 05:35:02 1998
>Last-Modified:
>Originator:     Ian Dall
>Organization:
	
>Release:        <NetBSD-current source date> 1 Jan 1998
>Environment:
	
System: NetBSD sibyl.chez-dall.org.au 1.3_BETA NetBSD 1.3_BETA (SIBYL) #0: Sat Dec 20 01:17:57 CST 1997 ian@sibyl.chez-dall.org.au:/usr3/netbsd-1.2/lsrc/sys/arch/pc532/compile/SIBYL pc532


>Description:
	
sys/types.h only defines u_long etc when _XOPEN_SOURCE is not defined,
however unistd.h has prototypes which use u_long etc when _XOPEN_SOURCE
is defined. This causes compilation errors for any programs which include
unistd.h.

>How-To-Repeat:
	
Create test.c with thes two lines:

#define _XOPEN_SOURCE 500
#include <unistd.h>

gcc -S test.c
In file included from test.c:2:
/usr/include/unistd.h:140: syntax error before `u_long'
/usr/include/unistd.h:151: syntax error before `fd_set'
/usr/include/unistd.h:177: syntax error before `ualarm'
/usr/include/unistd.h:177: warning: parameter names (without types) in function declaration
/usr/include/unistd.h:177: warning: data definition has no type or storage class
/usr/include/unistd.h:179: warning: parameter names (without types) in function declaration

>Fix:
	

Probably

#ifndef	_POSIX_SOURCE

in unistd.h should become

#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)

but i am unsure of the requirements of the XOPEN standard.
>Audit-Trail:
>Unformatted: