|
Boost : |
Subject: Re: [boost] [#pragma once]
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2009-04-13 08:06:35
Niels Dekker - address until 2010-10-10 wrote:
> Graham wrote:
>> Incredibuild (xoreax) and other parallel compilation systems have
>> problems with pragma once
>
> Thanks, Graham! (We're using IncrediBuild very much, at LKEB.) Now I
> see, it's at their FAQ:
> "When a source file includes one or more header files that are also
> included by the precompiled header and use the '#pragma once' directive,
> these header files may be #included more than once despite the #pragma
> once directive" http://xoreax.com/support_faq.htm#q122
>
> Bo Persson wrote:
>> The #pragma once depends on the compiler being able to correctly parse
>> the include paths for all possibly attached file systems. If it fails,
>> it might include the same file twice from seemingly different paths.
>
> I guess that's what typically might go wrong when using IncrediBuild, or
> other parallel compilation systems.
>
> Kind regards, Niels
You've clipped a lot of caveats there. To stop this over-generalization
from propagating here's the full FAQ entry:
Q: I'm getting the following warning:
"File includes the following header files that are also included by the
precompiled header, and use the '#pragma once' directive.
This may cause interoperability problems when using IncrediBuild to
build the precompiled-header and MSVC to build source files that use it,
or vice versa.
Refer to the FAQ section in the documentation for more details and
possible workarounds." What's wrong?
A: When a source file includes one or more header files that are also
included by the precompiled header and use the '#pragma once' directive,
these header files may be #included more than once despite the #pragma
once directive. This will happen only in .NET builds, in one of the
following 2 scenarios:
1. When the PCH was compiled using IncrediBuild and the source files
compiled without IncrediBuild.
2. When the PCH was compiled without IncrediBuild and the source files
compiled using IncrediBuild.
There are 2 possible workarounds for this issue:
1. Remove the explicit #include directive for these header files from
cpp files that use the PCH (the file will be included through the PCH).
2. Replace the #pragma once directive in the header file with the
following preprocessor code:
#ifndef __HEADER_NAME__
#define __HEADER_NAME__
<header file contents>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk