[Development] Rules for including private headers

Simon Hausmann simon.hausmann at digia.com
Mon Feb 17 12:48:33 CET 2014


On Monday 17. February 2014 10.46.12 Ulf Hermann wrote:
> > Sounds good to me. From what I read below, you just add the section about
> > private headers, right?
> 
> Yes.
> 
> >> * If you need to include qt_x11_p.h, always include it as the last
> >> header file.
> > 
> > This could go into the private headers section since it's private itself.
> 
> I'd rather just delete it. What is so significant about qt_x11_p.h that
> it needs its own rule here?
> 
> > Please merge all cases into one:
> > 	#include <private/whatever_p.h>
> 
> The argument for case 1 ("whatever_p.h") is that it's shorter and easier
> to see where the file is than with <private/whatever_p.h>. Both cases 1
> and 2 ("foo/bar/whatever_p.h") reduce the amount of indirection to look
> up the file and possibly speed up compile times that way. In case 3
> (<QtCore/private/whatever_p.h>), as we are using private API of a
> different module, that should really be visible in the code, I think.
> 
> I'm aware that those rules are pretty complex and the idea of one syntax
> to cover them all has its merits, but maybe we should take another look
> at the pros and cons.

I'm in favor of keeping the rules simple, and therefore like the plain


    #include <private/whatever_p.h>


If I really have doubts where a header is coming from, I just press F2 in 
creator, or better: Just hover with the mouse over the include and it tells me 
the absolute path in a tooltip.

#include <Module/private/whatever_p.h> is IMO redundant.

Simon



More information about the Development mailing list