[DVDnav-discuss] [PATCH]es

Nico Sabbi Nicola.Sabbi at poste.it
Fri Jun 6 10:17:15 CEST 2008


On Friday 06 June 2008 00:37:31 The Wanderer wrote:
> Nico Sabbi wrote:

>
> Er... I seem to recall a discussion, on one of the MPlayer mailing
> lists not terribly long ago, which ended up with participants in
> violent agreement on the point that "every header should provide
> everything it needs, period". 

yes, it's a  mever ending-topic, but I don't remember that
Michael or Ivan ever agreed with that point of view.
For sure I totally disagree with it.

> If things provided by dvdnav.h 
> require things provided by inttypes.h, then those latter things
> should be provided by dvdnav.h - either by being defined there
> directly or by the inclusion of some other file which defines them,
> such as inttypes.h itself.
>
> IOW, while a header should not include other headers just for the
> benefit of the files which include it, it *should* include other
> headers for its *own* benefit. It should never be intentionally
> possible to add one include line and thereby break the build solely
> because you did not also add a second include line. (This is, as it
> happens, a direct contradiction of your statement that "it's not
> headers' responsibility to include their dependencies".)

my point is that .h files define interfaces (macros, types and
functions), and as such they are dependent on the resources provided 
by the enclosing .c files or they would be .c files in their own 
respect.
If headers include other headers they can lead to macros and types
defined behind the back of .c files unaware of them, possibly
leading to redefinition and clashes.
Also, sometimes the order of inclusion of headers files _does_ matter
(although generally problems like that happen with badly written 
headers) but it's nonetheless a problem to consider.

If you read the man page of standard C functions you will often notice
the inclusion of 2 or 3 headers files, so why doesn't the second
header include the first? I guess for very good reasons :)

>
> That's what seems reasonable to me, anyway; if there is some reason
> why it would not be the case, I'd be interested to hear it. You've
> said that it "leads to bad coding", but aside from the possibility
> of failing to include a needed header because you haven't noticed
> that it's implicitly included by a header you already have (which
> is then the non-noticer's own fault), I don't see how...

because it encourages developers' unawareness of the needed resources,
that is IMO a bad practice




More information about the DVDnav-discuss mailing list