header includes

John Birch jbb at kdevelop.org
Fri Dec 1 20:59:47 UTC 2000


A golden rule of thumb with including header files is

if you have this.cpp with corresponding this.h always include this.h _first_ 
in this.cpp.

This way you guarantee that your header files are "complete" and don't depend 
on header files being included prior to it.

Another (more minor) rule of thumb is
group the headers in .cpp file as follows
#include this.h
#include other headers in this project
#include toplevel toolkit
#include base toolkit
#include system

Within each group, the include order is alphabetic, (alphabetic is an 
arbitary order that makes it much easier for humans to read). Why group them? 
Well it helps to catch bad dependencies in the headers.

Of course, before this you've made sure that your header only includes other 
headers that are _essential_ to it.

jbb
... and hence world peace will surely follow

-
to unsubscribe from this list send an email to kdevelop-devel-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop-devel mailing list