From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 10 05:53:27 2005 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4CF0C16A59A for ; Wed, 10 Aug 2005 05:52:58 +0000 (GMT) (envelope-from drosih@rpi.edu) Received: from smtp3.server.rpi.edu (smtp3.server.rpi.edu [128.113.2.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9A6B14470A for ; Wed, 10 Aug 2005 00:05:01 +0000 (GMT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp3.server.rpi.edu (8.13.0/8.13.0) with ESMTP id j7A04qFu020554; Tue, 9 Aug 2005 20:04:53 -0400 Mime-Version: 1.0 Message-Id: In-Reply-To: <200508092222.j79MM1DR013799@sora.hank.home> References: <200508092222.j79MM1DR013799@sora.hank.home> Date: Tue, 9 Aug 2005 20:04:52 -0400 To: Dirk GOUDERS From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: default X-RPI-SA-Score: undef - spam-scanning disabled X-Scanned-By: CanIt (www . canit . ca) on 128.113.2.3 Cc: hackers@freebsd.org Subject: Re: Include files that depend on include files 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: Wed, 10 Aug 2005 05:53:28 -0000 At 12:22 AM +0200 8/10/05, Dirk GOUDERS wrote: > > This is intentational. We try to avoid having headers bring in > > more then absolutly required when included. I'm not sure what > > your second question means. > >With my second question I wanted to ask if this intention is only >for kernel level code or a general one. I am asking this, because >somewhen in a project that I was not actually participating in I >heard or read a rule that roughly said: "all include files have to >include all files they depend on and compile cleanly", but that >project was on a user space program. It gets a little tricky. POSIX rules for include files include various requirements against "namespace pollution". So, if you bring in one particular include file, then you're supposed to be confident that it will only define the symbols that you expect from that one file. And yet you will need to have that include file reference some values which (according to standards) are defined by some other standard include file. You need one or two symbols, but you're not allowed to define any of the other symbols. To get around this in user-space, we do things like create /usr/include/sys/_types.h And then our include files include *that* file, and do not include the standard . This file, in turn, does not define any of the actual symbols. Let's say that some include file needs to know what typedef for 'off_t' is. The sys/_types.h file defines __off_t, and then the include file which needs off_t will do something like: #include #ifndef _OFF_T_DECLARED typedef __off_t off_t; #define _OFF_T_DECLARED #endif Thus, it has only defined the one name it actually needs, instead of defining all of the standard symbols in the real sys/types.h. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu