Re: Include files that depend on include files
On 2005-08-10 00:22, Dirk GOUDERS [EMAIL PROTECTED] 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. Well, first of all include files do not compile. Then, there are two different schools of thought on this matter: a) the purity and clean state of the namespace school, and b) the keep the header files a userlevel program has to include as few as possible school Both approaches have their advantages and drawbacks. AFAIK, in FreeBSD the first is preferred. - Giorgos ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
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 sys/types.h. This sys/_types.h 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 sys/_types.h #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. Can you point me to a real-life example where such a mechanism is used? I'd like to have a closer look at it. Dirk ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
Hi Dirk, Can you point me to a real-life example where such a mechanism is used? I'd like to have a closer look at it. /usr/include/sys/types.h :-) Regards, -- Jeremie Le Hen jeremie at le-hen dot org ttz at chchile dot org ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
At 12:06 PM +0200 8/10/05, Dirk GOUDERS wrote: 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 sys/types.h. This sys/_types.h 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 sys/_types.h #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. Can you point me to a real-life example where such a mechanism is used? I'd like to have a closer look at it. The above lines came from FreeBSD's /usr/include/sys/stat.h Note that it includes sys/_types.h and not sys/types.h There are many other examples in the FreeBSD system includes, at least once you get to the 5.x-series of FreeBSD. I don't remember if we were doing that in the 4.x-series. -- Garance Alistair Drosehn= [EMAIL PROTECTED] Senior Systems Programmer or [EMAIL PROTECTED] Rensselaer Polytechnic Instituteor [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
Can you point me to a real-life example where such a mechanism is used? I'd like to have a closer look at it. /usr/include/sys/types.h :-) Thank you :-) Now, I found the comment in /usr/include/machine/ansi.h that also describes this mechanism. Thanks for all other answers, as well. Dirk ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
The above lines came from FreeBSD's /usr/include/sys/stat.h Note that it includes sys/_types.h and not sys/types.h There are many other examples in the FreeBSD system includes, at least once you get to the 5.x-series of FreeBSD. I don't remember if we were doing that in the 4.x-series. In 4.x I did not find any referece to sys/_types.h but Jeremie pointed me to another example. And now, I also can have a look at the newer version of stat.h via cvsweb. Thanks a lot. Dirk ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Include files that depend on include files
Hello, I am currently playing with the KLD facility on a 4.11-STABLE system and noticed that there are some include files that need other files included before them, e.g. sys/module.h and sys/linker.h cannot be preprocessed/compiled without including other necessary files before them. Is that intentional? And if yes, is there a difference of such a rule between kernel include files and those that are normally included in user space code? Dirk ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
On Tue, Aug 09, 2005 at 11:49:57PM +0200, Dirk Gouders wrote: Hello, I am currently playing with the KLD facility on a 4.11-STABLE system and noticed that there are some include files that need other files included before them, e.g. sys/module.h and sys/linker.h cannot be preprocessed/compiled without including other necessary files before them. Is that intentional? And if yes, is there a difference of such a rule between kernel include files and those that are normally included in user space code? 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. -- Brooks -- Any statement of the form X is the one, true Y is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 pgpfYSHJao4Sc.pgp Description: PGP signature
Re: Include files that depend on include files
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. Dirk ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Include files that depend on include files
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 [EMAIL PROTECTED]
Re: Include files that depend on include files
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 sys/types.h. This sys/_types.h 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 sys/_types.h #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= [EMAIL PROTECTED] Senior Systems Programmer or [EMAIL PROTECTED] Rensselaer Polytechnic Instituteor [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]