Reduced header file inclusions

Jens Seidel jensseidel at users.sf.net
Tue Apr 10 08:35:36 MDT 2007


On Tue, Apr 10, 2007 at 06:56:03AM -0700, Robby Stephenson wrote:
> Thanks for the patch, Jens. Did you create it with some sort of tool that 
> checks include files, or just a lot of source file reading? :)

Yep, the tool is called vim :-)

It was fairly easy, probably because of two facts:
 * I checked only header files, no cpp files and only in src/
   (yesterday I checked also src/fetch/*.h)
 * Only very few headers are currently included, so I had a good start.
 
Just a fast recall of the rules when a class declaration (class X;)
sufficies instead of a definition (#include "X.h"):
X function(X*, X&) # X is a return type or used as pointer/reference

The inclusion is always (?) required in the following cases:
class Y : public X # inheritance
X m_x              # variable definition
Y<X>               # used in template parameters?

Once I found #include "X.h" I just checked whether occurrences of "X"
need to be defined or declared. (Only very few header files define
types or classes which differ from the header file name.)

Once there was an error during compilation I added the missing inclusion
into the cpp file. I did not parsed cpp file and relied on the error
messages!

Now I think I found an easy test to check header files: Let's just try to
compile:
#include "X.h"

void dummyFunction() {}

for all headers X.h. I will do so.

> I do remember having some compilation issues of Fedora for some reason, 
> because of some include files I didn't think I needed. I don't know if that 
> was an issues because of an old KDE version or some Fedora specific, 
> though.

All remaining errors should be related to either bogus KDE or Qt header
files, or missing inclusions in cpp files. I'm sure the second reason is
the problem on Fedora and indicates already a problem in the original
source code of tellico. I suggest to just commit the patch and to add
missing includes later if required.

If a KDE or Qt header file depends on another header file it could be
added as a workaround together with a big fat warning after the include
and a bug should be filed.
 
> > I just tested your patch on a fairly wide range of gcc versions. The
> > Debian gcc-snapshot was happy with it. Considering this one is supposed
> > to be very strict regarding #include's, that's a good news. However, it

Yep, I read this about gcc-snapshot as well, but removed no STL headers
but only KDE and Qt stuff. This needs to be tested with different KDE
and Qt header files.

> > failed when trying to build in a dapper chroot. Given that it's only an
> > 8 months old distribution, I'm afraid it might affect some others...

Every person who wants to compile tellico by it's own (package managers, ...)
should have no big problems to add a single missing include and it will
stabilize soon ...

> > A slightly modified patch is on an other of my machines, I will post it
> > soon.

I would like to see what I missed ...

PS: I know it's not one of the most useful patches you ever received, but
let's start with minor issues ...
Yesterday I worked on proper sorting of dependent columns.

Jens



More information about the tellico-users mailing list