[Development] #pragma once
Konstantin Tokarev
annulen at yandex.ru
Thu Jan 25 11:31:02 CET 2018
25.01.2018, 13:27, "Mathias Hasselmann" <mathias at taschenorakel.de>:
> Let's see what people who know much more about compiler features than
> any of us think about "#pragma once". Let's check what GCC and Clang do
> for their C++ library headers:
>
> $ grep -r pragma.*once /usr/include/clang/5.0.0/include
> /usr/include/c++/7.2.0/
> $
>
> ...and this is about headers that target exactly one compiler and are
> known to be locally installed.
The latter statement is not exactly true, both libstdc++ and libc++ can be used
by many compilers, and they also aren't guaranteed to be locally installed.
>
> Hope this helps,
> Mathias
>
> Am 24.01.2018 um 13:19 schrieb Mitch Curtis:
>>> -----Original Message-----
>>> From: Ville Voutilainen [mailto:ville.voutilainen at gmail.com]
>>> Sent: Wednesday, 24 January 2018 1:11 PM
>>> To: Mitch Curtis <mitch.curtis at qt.io>
>>> Cc: Alexander Nassian <nassian at bitshift-dynamics.com>; development at qt-
>>> project.org
>>> Subject: Re: [Development] #pragma once
>>>
>>> On 24 January 2018 at 12:34, Mitch Curtis <mitch.curtis at qt.io> wrote:
>>>>> -----Original Message-----
>>>>> From: Ville Voutilainen [mailto:ville.voutilainen at gmail.com]
>>>>> Sent: Wednesday, 24 January 2018 11:25 AM
>>>>> To: Alexander Nassian <nassian at bitshift-dynamics.com>
>>>>> Cc: Mitch Curtis <mitch.curtis at qt.io>; development at qt-project.org
>>>>> Subject: Re: [Development] #pragma once
>>>>>
>>>>> On 24 January 2018 at 12:22, Alexander Nassian <nassian at bitshift-
>>>>> dynamics.com> wrote:
>>>>>> Maybe because it’s not part of the C++ standard?
>>>>>
>>>>> #pragma once is not a replacement for include guards.
>>>>
>>>> Why not?
>>>>
>>>>> It's not part of the C++ standard because it doesn't always work
>>>>
>>>> In which ways? My quick search gave me these:
>>>>
>>>> https://stackoverflow.com/a/1946730/904422
>>>> https://en.wikipedia.org/wiki/Pragma_once#Caveats
>>>
>>> That wikipedia link seems to describe the problems fairly accurately.
>>
>> Do we have that issue in Qt?
>>
>>>>> and modules are a superior solution anyway.
>>>> How so?
>>>
>>> Because you can import the same module multiple times without concerns
>>> about re-definitions, and that import is much faster than parsing a header
>>> file.
>> _______________________________________________
>> Development mailing list
>> Development at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/development
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
--
Regards,
Konstantin
More information about the Development
mailing list