public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@engr.sgi.com>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: pluto@pld-linux.org, linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [2.6.11.3] gcc4 / psmouse.h - compilation fix.
Date: Sun, 13 Mar 2005 13:37:02 -0800	[thread overview]
Message-ID: <20050313133702.081001e9.pj@engr.sgi.com> (raw)
In-Reply-To: <200503131230.03938.dtor_core@ameritech.net>

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
libps2.h.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401

      reply	other threads:[~2005-03-13 21:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-13 13:20 [2.6.11.3] gcc4 / psmouse.h - compilation fix Paweł Sikora
2005-03-13 16:48 ` Dmitry Torokhov
2005-03-13 16:54   ` Paweł Sikora
2005-03-13 17:30     ` Dmitry Torokhov
2005-03-13 21:37       ` Paul Jackson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050313133702.081001e9.pj@engr.sgi.com \
    --to=pj@engr.sgi.com \
    --cc=akpm@osdl.org \
    --cc=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pluto@pld-linux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox