[DVDnav-discuss] [PATCH]es
The Wanderer
inverseparadox at comcast.net
Fri Jun 6 00:37:31 CEST 2008
Nico Sabbi wrote:
> On Thursday 05 June 2008 17:51:39 Rafaël Carré wrote:
>> Le Thu, 5 Jun 2008 10:59:44 +0200,
>>
>> Nico Sabbi <Nicola.Sabbi at poste.it> a écrit :
>>> no good. I don't like to make headers include other headers
>>> because these practice leads to bad coding. Include <inttypes.h>
>>> in your .c file intead
>>
>> Every .c file which includes dvdnav.h will need inttypes.h anyway,
>> so why not including it for them ?
>
> for the reason I posted: it's not headers' responsability to include
> their dependencies. Headers just define their types and functions,
> and IMO they should never work behind the back of the including .c
> files
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". 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".)
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...
--
The Wanderer
Warning: Simply because I argue an issue does not mean I agree with any
side of it.
Secrecy is the beginning of tyranny.
More information about the DVDnav-discuss
mailing list