#ifdef vs #if for feature checks

Lubos Lunak l.lunak at suse.cz
Wed Mar 20 08:27:26 PDT 2013


On Tuesday 19 of March 2013, Thomas Arnhold wrote:
> On 19.03.2013 00:02, Norbert Thiebaud wrote:
> > otoh, #pragma once is supported by all the compiler we use isn't it ?
> > so if we are going to change it, why not use that instead.
>
> There are some discussions about that on the Internet. Most interesting:
> Some kind of benchmark comparison at
>
> http://tinodidriksen.com/2011/08/31/cpp-include-speed/
>
> Looks like header guards as we have them are the best solution on gcc,
> but the worst for MSVC and no combination would be acceptable compared
> to 'plain' header guard with gcc.

 That's so suspicious just from considering the idea that there could possibly 
be any noticeable difference. I can't quite imagine how broken the 
implementation of #pragma once would have to be to be slower than include 
guards (and presumably they're both implemented the same way). I tried with 
10000 include files with GCC and the difference, if any, is just lost in the 
noise.

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list