A New Krazy Checker for #include

David Faure faure at kde.org
Mon Apr 9 17:25:59 BST 2007


On Monday 09 April 2007, Andras Mantia wrote:
> On Sunday 08 April 2007, Cyrille Berger wrote:
> > > > Other ideas that I may implement one day (or maybe someone will
> > > > do me): - if including an installed header, always use #include
> > > > <foo.h>, not "foo.h" - foo.cpp should always include its own
> > > > header foo.h first
> > >
> > > What is the reason for this?
> >
> > that way you are certain that "foo.h" can be include in a file
> > without the need of including an other header. For instance:
> > foo.h contains:
> > class myWidget : public QWidget
> > {};
> > And in foo.cpp:
> > #include<QWidget>
> > #include "foo.h"
> >
> > build, but each time you want to include foo.h you also have to
> > include QWidget, it's an easy example, but it's annoying to have to
> > track headers.
> 
> And how will this be avoided by using < >? 
Unrelated; the answer was about why "foo.cpp should always include its own header foo.h first".

> The solution for the above problem is that in the implementation files 
> always include first your own headers

Yes that's what Allen and Andras said ;-)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list