[Development] #pragma once

Oswald Buddenhagen oswald.buddenhagen at qt.io
Wed Jan 24 15:30:38 CET 2018


On Wed, Jan 24, 2018 at 06:09:06AM -0800, Thiago Macieira wrote:
> On Wednesday, 24 January 2018 03:53:18 PST Konstantin Tokarev wrote:
> > That's said, if headers are never copied it's safer to use #pragma once than
> > include guards
> 
> And you know what copies headers? make install
> 
> If you do an installed build of each module, then the compiler will have to 
> add -I for the target as well as for the source dir. So if you build a module 
> while that module is already installed, it will find the installed headers and 
> include both.
> 
> That said, I am not sure that type of build works anyway because of this very 
> reason and that different library files will be present, causing linking 
> errors too.
> 
of course this is not supposed to work. if the current source directory
doesn't shadow the installation directory completely, that's a bug.
there are some cases like that (because our build system sucks) and the
only workaround for that is uninstalling the previous build. in fact,
you're the one who always argued for that "solution" (even in the cases
we eventually fixed).

but that's only tangentially related to the issue at hand, because the
compiler would still pick only one of the files under normal
circumstances. a problem would arise if different include styles in
different files lead to different headers being picked up from the same
-I list. it's fairly hard to construct such a case, and it *probably*
doesn't appear inside qt's "regular" build system (that specifically
excludes webkit & webengine).




More information about the Development mailing list