[Qt-creator] Use #pragma once as default instead of header guards

Milian Wolff mail at milianw.de
Wed Jan 13 14:53:21 CET 2016

On Mittwoch, 13. Januar 2016 10:55:22 CET Bubke Marco wrote:
> Hello
> With the clang code model there is a problem to generate a preamble file
> with header guards. Imaging a preamble file is like a automatically pre
> compiled header for the include block at the top. But there are
> limitations. One is that every ifndef has to match is #endif inside of the
> preamble but this not the case for header guards.
> #ifndef HEADER_GUARD
> #define HEADER_GUARD
> #include <QtGui> // this would be compiled in the preamble once
> void foo()
> {
>    auto bahn = nullptr;
> }
> #endif
> We don't generate a preamble for this case because the opening ifndefs is
> not matching the endif. In that case the clang model will be very slow!
> So I propose we change our wizards to utilize #pragma once and use it for
> every new file. We can change header files where we need code completion on
> demand too.
> https://en.wikipedia.org/wiki/Pragma_once
> Best regards, Marco

Hey Marco,

can you elaborate on this please? I haven't seen such issues in KDevelop so 
far. What do you mean by "matching endif"? The header file seems to have an 
opening #ifndef and a matching #endif.


Milian Wolff
mail at milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20160113/4e3a92bd/attachment.sig>

More information about the Qt-creator mailing list