[Qt-creator] Use #pragma once as default instead of header guards
Ziller Eike
Eike.Ziller at theqtcompany.com
Fri Jan 22 12:29:58 CET 2016
Blinding out the discussion about whether and how the Clang code model should support header guards better,
I do not see voices against actually switching to use “#pragma once” within Qt Creator headers.
So I have created this for our coding style:
https://codereview.qt-project.org/147008
Br, Eike
> On Jan 13, 2016, at 1:54 PM, Hunger Tobias <Tobias.Hunger at theqtcompany.com> wrote:
>
> On Mi, 2016-01-13 at 12:15 +0000, Bubke Marco wrote:
>> We support it but it will be slow. It is your decision. Anyway how often do
>> you need code completion in the header file.
>
> I agree with Christian that we should not change the coding standard to work
> around problems in the code model.
>
>> Maybe we can fix it in the future but it depends on Clang.
>
> Good.
>
>> Anyway I don't want to force you to anything. It was about the future. So
>> #pragma once would be allowed for the people who want to use it.
>
> No. A coding standard is supposed to help developers work with code in their
> project that they are not familiar with by writing down a basic set of rules
> that provide a base-line of consistency. This is only possible when everybody
> follows the same set of rules. That is why we need a broad consensus on coding
> style rules, with "do whatever you want" being an option only for rules that the
> community is split on.
>
> I do not think #pragma once is such an item:
>
> * According to Marco #pragma once is supported by all compilers we support with
> Qt Creator.
>
> * It is less to type
>
> * It removes the need to come up with a long name that is unique in the project
>
> * It prevents unexpected results when that name is not as unique as you thought
>
> * It prevents unexpected results when you mistype that long name once in the
> #define or #ifndef lines.
>
> So I am in favor changing the coding style to ask developers to use #pragma once
> in all new headers.
>
> I think it will most likely even make sense to update existing headers in one
> patch and be done with this change.
>
> Best Regards,
> Tobias
>
> --
> Tobias Hunger, Senior Software Engineer | The Qt Company
> The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
> Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja Sitz der Gesellschaft:
> Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
--
Eike Ziller, Principle Software Engineer - The Qt Company GmbH
The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Qt-creator
mailing list