From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 25 11:24:10 2011 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0531F106566B for ; Mon, 25 Apr 2011 11:24:10 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx06.syd.optusnet.com.au (fallbackmx06.syd.optusnet.com.au [211.29.132.8]) by mx1.freebsd.org (Postfix) with ESMTP id EB0958FC19 for ; Mon, 25 Apr 2011 11:24:08 +0000 (UTC) Received: from mail04.syd.optusnet.com.au (mail04.syd.optusnet.com.au [211.29.132.185]) by fallbackmx06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p3P9A6wR025111 for ; Mon, 25 Apr 2011 19:10:06 +1000 Received: from c122-106-155-58.carlnfd1.nsw.optusnet.com.au (c122-106-155-58.carlnfd1.nsw.optusnet.com.au [122.106.155.58]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p3P9A0e5002604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Apr 2011 19:10:03 +1000 Date: Mon, 25 Apr 2011 19:10:00 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Robert Andersson In-Reply-To: <201104250815.p3P8FoLj030509@red.freebsd.org> Message-ID: <20110425190527.K3464@besplex.bde.org> References: <201104250815.p3P8FoLj030509@red.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org Subject: Re: misc/156637: sys/types.h can't be included when _XOPEN_SOURCE is defined X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2011 11:24:10 -0000 On Mon, 25 Apr 2011, Robert Andersson wrote: > >> Description: > When including with _XOPEN_SOURCE defined to 500 or higher, compila > tion will fail with a message similar to this one (using clang, gcc fails with a > similar message): > > In file included from main.c:3: > /usr/include/sys/file.h:161:2: error: unknown type name 'u_int' > u_int xf_flag; /* flags (see fcntl.h) */ > > u_int is defined in types.h, but it is wrapped in a #if __BSD_VISIBLE. > > __BSD_VISIBLE is defined in cdefs.h only if _POSIX_C_SOURCE is not defined (whic > h it is if _XOPEN_SOURCE is defined). > > I found the following (short) thread about this problem from 2009: > http://www.mail-archive.com/freebsd-hackers@freebsd.org/msg69469.html > > ... >> Fix: > I'm not sure what the correct solution is. Any one of the following would solve the problem: > * sys/file.h should not use u_int > * The relevant parts of sys/file.h should be wrapped in #if __BSD_VISIBLE > * The definition of u_int should not be wrapped in #if __BSD_VISIBLE > * _XOPEN_SOURCE >= 500 should not imply _POSIX_C_SOURCE > * _POSIX_C_SOURCE should not stop __BSD_VISIBLE from being defined. I've used the following fix (the first of the above) for 10 years or so (it got lost in fixes for mounds of style bugs in ). I didn't notice it in connection with _XOPEN_SOURCE, but by general principles. % Index: file.h % =================================================================== % RCS file: /home/ncvs/src/sys/sys/file.h,v % retrieving revision 1.65 % diff -u -2 -r1.65 file.h % --- file.h 19 Jun 2004 11:38:00 -0000 1.65 % +++ file.h 20 Jun 2004 02:11:04 -0000 % @@ -151,5 +142,5 @@ % void *xf_data; /* file descriptor specific data */ % void *xf_vnode; /* vnode pointer */ % - u_int xf_flag; /* flags (see fcntl.h) */ % + unsigned xf_flag; /* flags (see fcntl.h) */ % }; % Bruce