[Development] Rules for including private headers

Thiago Macieira thiago.macieira at intel.com
Fri Feb 14 17:59:04 CET 2014


Em sex 14 fev 2014, às 11:03:02, Ulf Hermann escreveu:
> If you need to include private headers there are four cases with 
> different syntax. Various build system magic makes those possible but 
> that will not be discussed here.
> 
> 1. The header, e.g. whatever_p.h, is in the same directory as the file 
> including it. In this case write:
> 
>              #include "whatever_p.h"
> 
> 2. The header is in a different directory but in the same module. In 
> this case locate the base directory of the module and include relative 
> to that with quotation marks:
> 
>              #include "foo/bar/whatever_p.h"
> 
> foo is a subdirectory of the same directory the .pro file is in if 
> you're using qmake.
> 
> 3. You want to include a private header from a different module, e.g. 
> QtCore. Be careful with that as it creates interdependency between 
> modules. If you're sure you need to do that make sure the project 
> dependencies are set up correctly and include like this:
> 
>              #include <QtCore/private/whatever_p.h>
> 
> It doesn't matter if whatever_p.h is in the base directory of its 
> project or in some subdirectory foo/bar/.
> 
> 4. You want to include a private header from a different project in the 
> same module. This happens frequently when writing writing a test case or 
> an example. If that's not what you're doing you should be careful, see 
> 3. In that case:
> 
>              #include <private/whatever_p.h>

Please merge all cases into one:

	#include <private/whatever_p.h>
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list