[MPlayer-dev-eng] [RFC] port 'make checkheaders' from FFmpeg

Uoti Urpala uoti.urpala at pp1.inet.fi
Wed Feb 27 05:19:12 CET 2008


On Wed, 2008-02-27 at 04:57 +0100, Alban Bedel wrote:
> On Wed, 27 Feb 2008 00:34:18 +0100
> Diego Biurrun <diego at biurrun.de> wrote:
> > Why would that be inacceptable?  It sure seems to work for FFmpeg.
> 
> Because a header have no business doing this kind of things. It
> completely hide which API the header is using. This just lead to an even
> complexer dependency tree which can bite you in even subtler ways, like
> this for ex:
> 
> foo.h:
> #include <stdio.h>
> ....
> 
> file.c:
> #if DEFINED_ON_THE_DEV_BOX
> #include "foo.h"
> #endif
> ....
> printf("No declaration for some ppl, but no warning for the dev");

And here's an example in the other direction:

foo.h:
<use math.h definitions without including math.h>

file.c:
<no math.h include>
#ifdef NOT_DEFINED_ON_THE_DEV_BOX
#include "foo.h"
#endif

Bugs are harder to avoid in the latter case. It's more realistic to
expect people to notice that file.c uses a definition but does not
include the header, than to notice that foo.h uses a definition but
file.c does not include the header.

The basic issue is simple: it's much more realistic to manually maintain
an accurate list of what headers (and under what conditions) are
required BY THIS FILE, than to manually maintain an accurate list of
what headers (and under what conditions) are required by this file, OR
its dependencies, OR their dependencies recursively.

> Inside a given API, when you in fact have more or less a splited
> header, or for "public" headers it can make sense. But referencing
> headers from unrelated API just make following the real dependencies
> harder. And it make adding senseless dependencies way too easy.

Adding recursive includes to every file using the header makes leaving
senseless dependencies in the files way too easy.

> And honestly, in practice, how often do the dependencies of a well
> written and widely used header change?

"Well written headers"... doesn't sound relevant to MPlayer...
Depending/not depending on something like stdint.h can easily change.




More information about the MPlayer-dev-eng mailing list