On Mon, Nov 24, 2014 at 04:37:40PM +0100, a b via smartos-discuss wrote: > That is a very contentious statement: I have had arguments over this > with developers wanting me to perform their port work for them, which > ended up with having to edit hundreds of files to #include the missing > header file in question, when all that was needed was to include it > in the top level header which all those files were including. > > The colleague in question objected very strongly to including it into the > top level header under the pretense that it would slow the build down, > which I vehemently disagreed with, since that is easily resolved with the > following construct: > > #ifndef PATH_MAX > #include <limits.h> > #endf > > ...causing the preprocessor to process it once and only once. > > "13. Rule of Economy: Programmer time is expensive; conserve it in > preference to machine time." > http://www.faqs.org/docs/artu/ch01s06.html#id2878666
This has nothing to do with build time and everything to do with maintainability. If the header is included where its contents are referenced, confusion and the risk of nested-include logic errors appearing later are minimised; every file that consumes the header's contents is expected to #include it directly. Since all headers in illumos are guarded, there is never a need to fear duplicate inclusion (or excessive compiler processing time, if that were worth fearing in the first place). Opening and reading a file that is already in the ARC is effectively free on modern systems, so simplifying the code takes precedence. We agree that engineering time is expensive; tracking down build failures caused by inclusion problems is wasteful and best avoided by following this rule. The rule I have described is the one used in ON (with a few exceptions where standards-mandated behaviour requires otherwise). If you are making patches to HDF5 for pkgsrc, you need to follow the same rule. If it's your own software you're not planning to contribute, you're of course welcome to do what you think best. ------------------------------------------- smartos-discuss Archives: https://www.listbox.com/member/archive/184463/=now RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00 Modify Your Subscription: https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb Powered by Listbox: http://www.listbox.com
