Re: [188.8.131.52] gcc4 / psmouse.h - compilation fix.
From: Paul Jackson
Date: Sun Mar 13 2005 - 16:43:18 EST
Dmitry, responding to Pawe__:
> > IMHO each header (e.g. psmouse.h) should include headers for types it uses.
> Hmm, I thought it was other way around
I tend to agree with Pawe__ here.
There are two extremes here that I would avoid. Do not try to include
in source files every header that is directly or indirectly needed, nor
try to minimize inclusions in header files by relying on every possible
prerequisite inclusion by the includers of that header.
Rather - think about the interface presented and used.
A source file should include headers for everything that it manifestly
makes use of (even if that means it happened to include something that
was also indirectly included elsewhere). And no more.
A header file should provide all the inclusions that its users
(includers) will need to make use of what is in that header file,
without presuming that any user will already have included something
else. And no less.
In this case, it seems that the header drivers/input/mouse/psmouse.h
requires the size of a struct ps2dev. So I would think that psmouse.h
should include linux/libps2.h, as this patch provides for. The users
of psmouse.h should not have to know of this dependency.
Respect the interfaces. They are one of the means whereby we partial
out responsibility for keeping code sane, in the face of rapid,
conflicting changes from many developers across many architectures and
drivers, where no one individual can test all possible configurations.
A user of psmouse.h should not be required to include the libps2.h
header, because someday a user of psmouse.h that didn't do this, but was
working anyway because it happened to get libps2.h from some other
indirect inclusion, will get broken when someone working in a quite
different area happens to deprive our hapless psmouse.h user of its
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@xxxxxxxxxxxx> 1.650.933.1373, 1.925.600.0401
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/