From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 19 09:54:24 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DD3F1065679 for ; Thu, 19 Nov 2009 09:54:24 +0000 (UTC) (envelope-from matthias.andree@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 8BF538FC18 for ; Thu, 19 Nov 2009 09:54:23 +0000 (UTC) Received: (qmail invoked by alias); 19 Nov 2009 09:27:42 -0000 Received: from balu.cs.uni-paderborn.de (EHLO balu.cs.uni-paderborn.de) [131.234.21.37] by mail.gmx.net (mp072) with SMTP; 19 Nov 2009 10:27:42 +0100 X-Authenticated: #428038 X-Provags-ID: V01U2FsdGVkX19amZAbRW9aAVq199H4q3f93St5omYMPPwt0XM0WE b/AntfcRoovycT Received: from localhost ([127.0.0.1] helo=balu.cs.uni-paderborn.de) by balu.cs.uni-paderborn.de with esmtp (Exim 4.69) (envelope-from ) id KTCNM5-0004H4-ND for freebsd-hackers@freebsd.org; Thu, 19 Nov 2009 10:27:41 +0100 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "freebsd-hackers@freebsd.org" Date: Thu, 19 Nov 2009 10:27:41 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Matthias Andree" Organization: Message-ID: User-Agent: Opera Mail/10.01 (Win32) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.48 Subject: header file bug sys/types.h sys/file.h vs. _XOPEN_SOURCE standard X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2009 09:54:24 -0000 Greetings, this little C program (which is actual a minimum excerpt from sysutils/e2fsprogs) fails to compile on - among others - 8.0-PRERELEASE: $ cat fail.c #define _XOPEN_SOURCE 600 #include $ gcc -W -Wall -O -c fail.c In file included from fail.c:2: /usr/include/sys/file.h:161: error: expected specifier-qualifier-list before 'u_int' I can get the code to compile by removing the "#define _XOPEN_SOURCE 600". This happens here: 146 /* 147 * Userland version of struct file, for sysctl 148 */ 149 struct xfile { 150 size_t xf_size; /* size of struct xfile */ 151 pid_t xf_pid; /* owning process */ 152 uid_t xf_uid; /* effective uid of owning process */ 153 int xf_fd; /* descriptor number */ 154 void *xf_file; /* address of struct file */ 155 short xf_type; /* descriptor type */ 156 int xf_count; /* reference count */ 157 int xf_msgcount; /* references from message queue */ 158 off_t xf_offset; /* file offset */ 159 void *xf_data; /* file descriptor specific data */ 160 void *xf_vnode; /* vnode pointer */ !! 161 u_int xf_flag; /* flags (see fcntl.h) */ 162 }; The flow here is as follows: 1. sys/file.h (non-standard header) includes sys/types.h (POSIX/XSI standard header) and implictly sys/cdefs.h 2. since _XOPEN_SOURCE is defined, nonstandard symbols such as u_int aren't defined by the standard headers (this is in line with IEEE Std 1003.1-2008) 3. sys/file.h uses this non-standard and undefined u_int and breaks. I've talked to Theodore Y. Ts'o, who is the sysutils/e2fsprogs upstream maintainer and proposed to remove the _XOPEN_SOURCE definition (my idea was that the code shouldn't be claiming standards compliance while it uses non-standard headers), but he refused that (since it would break the e2fsprogs build on Solaris). Should non-standard system headers break if an application defines one of the standard feature test macros? Or could sys/file.h be changed (for instance by replacing u_int by unsigned int) to tolerate POSIX and XSI feature test macros? TIA. Cheers -- Matthias Andree mandree freebsd org