Re: [patch,rfc] make depencies on header files explicit

From: Sandy Harris (pashley@storm.ca)
Date: Fri Jul 05 2002 - 01:20:30 EST


Stephen Rothwell wrote:

> > It seems to be quite common to assume that sched.h and all the other
> > headers it drags in are available without declaration anyways. Since
> > I aim at invalidating this assumption by removing all unneccessary
> > includes, I have started to make dependencies on header files included
> > by sched.h explicit.
> > This is, again, just a small start, a patch covering the whole include/
> > subtree would be approximately 25 times as large. However, before I'll
> > dig into this further, I'd like to make sure I haven't missed some
> > implicit rules about which headers might be assumed available, or should
> > be included by the importing .c file, or something like that.
> > So any comments about this project are welcome.
>
> Let me encourage you! IMHO any source file (and here I include header
> files) should include all the header files it depends on. This gives us
> at least some chance of keeping the headers consistant with their usage.
 
I thought conventional wisdom was that header files should never #include
other headers, and .c files should explicitly #include all headers they
need.

Googling on "nested header" turns up several style guides that agree:
http://www.cs.mcgill.ca/resourcepages/indian-hill.html
http://www.doc.ic.ac.uk/lab/secondyear/cstyle/node5.html

and others that say it is controversial, can be done either way:
http://www.eskimo.com/~scs/C-faq/q10.7.html

Am I just off base in relation to kernel coding style? Or would getting
rid of header file nesting be a useful objective.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jul 07 2002 - 22:00:14 EST