[Mesa-dev] Mesa include guard style. (Was: [PATCH] i965/cfg: Remove redundant #pragma once.)

Francisco Jerez currojerez at riseup.net
Thu Mar 10 03:04:15 UTC 2016


Matt Turner <mattst88 at gmail.com> writes:

> On Wed, Mar 9, 2016 at 1:37 PM, Francisco Jerez <currojerez at riseup.net> wrote:
>> Iago Toral <itoral at igalia.com> writes:
>>
>>> On Tue, 2016-03-08 at 17:42 -0800, Francisco Jerez wrote:
>>>> brw_cfg.h already has include guards, remove the "#pragma once" which
>>>> is redundant and non-standard.
>>>
>>> FWIW, I think using both #pragma once and include guards is a way to
>>> keep portability while still getting the performance advantage of
>>> #pragma once where it is supported.
>>>
>> It's highly unlikely to make any significant difference on any
>> reasonably modern compiler.  I cannot measure any change in compilation
>> time locally from my cleanup.
>>
>>> Also it seems that we do the same thing in many other files...
>>>
>> Really?  I'm not aware of any other file where we use both.
>
> There are quite a few in glsl/

Heh, apparently you're right.  Anyway it seems rather pointless to use
'#pragma once' in a bunch of scattered header files with the expectation
to gain some speed, the improvement from a single header file is so
minuscule (if it will make any difference at all on a modern compiler
and compilation workload, which I doubt) that we would have to use it
universally in order to have the chance to measure any improvement.

Can we please just decide for one of the include guard styles and use it
consistently?  Given that the majority of header files in the Mesa
codebase use old-school define guards, that it's the only standard
option, that it has well-defined semantics in presence of file copies
and hardlinks, and that the performance argument against it is rather
dubious (although I definitely find '#pragma once' prettier and more
concise), I'd vote for using preprocessor define guards universally.

What do other people think?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160309/9ee11988/attachment.sig>


More information about the mesa-dev mailing list