#ifdef vs #if for feature checks

Thomas Arnhold thomas-libo at arnhold.org
Mon Mar 18 21:55:38 PDT 2013


On 19.03.2013 00:02, Norbert Thiebaud wrote:
> On Mon, Mar 18, 2013 at 11:17 AM, Lubos Lunak <l.lunak at suse.cz> wrote:
>> On Monday 18 of March 2013, Tor Lillqvist wrote:
>>>> Sounds great to me too; though of course I'd prefer to keep the diff
>>>> smaller and not replace all the header guards:
>>>>
>>>> #ifndef INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
>>>> #define INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
> ...
>>> Oh the other hand, it would be nice if the header guards were
>>> consistently named... and didn't start with an underscore (such
>>> identifiers are supposed to be reserved for the language and/or OS
>>> implementation, unless I am mistaken). Somebody just needs to come up
>>> with a consistent naming style and do it (with some nice script). (The
>>> style of above example would be fine with me.)
>>
>>   Yes, a script should be enough for this. And yes, "somebody" just needs to do
>> it :).
>
> 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.

Thomas


More information about the LibreOffice mailing list