Re: Include files that depend on include files

From: Robert Watson (rwatson_at_FreeBSD.org)
Date: 08/10/05

  • Next message: M. Warner Losh: "Re: Bluetooth GPS for timekeeping?"
    Date: Tue, 9 Aug 2005 23:34:49 +0100 (BST)
    To: Dirk GOUDERS <gouders@et.bocholt.fh-ge.de>
    
    

    On Wed, 10 Aug 2005, 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.

    In general, in the role the operating system vendor, it's important to
    minimize "header pollution" as much as possible. Unlike C++, C doesn't
    have a notion of structured use of the name space, and if things are
    massively nested included, that dramatically increases the chance of a
    conflict of use between "the system" and a user application. You'll
    notice that increasingly, FreeBSD-specific defines are prefixed with '_',
    as that indicates use of reserved "you're the system" symbol space. For
    example, the "#ifdef KERNEL"'s all over the place became "#ifdef _KERNEL",
    as there's no reason an application shouldn't use a define named KERNEL.

    The rules are a bit different if you're the application, although it's in
    your interest to include as a few unnecessary headers as possible, to
    reduce the chances of getting definitions that conflict with your
    application.

    Robert N M Watson

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: M. Warner Losh: "Re: Bluetooth GPS for timekeeping?"

    Relevant Pages