[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] PCH

From: Greg Chicares
Subject: Re: [lmi] PCH
Date: Sun, 5 Jun 2016 22:04:32 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0

On 2016-06-05 16:53, Vadim Zeitlin wrote:
> On Sun, 5 Jun 2016 16:29:17 +0000 Greg Chicares <address@hidden> wrote:
> GC> On 2016-06-05 15:36, Vadim Zeitlin wrote:
> GC> >  Does this mean I could propose a patch enabling PCH for MSVC now?
> GC> 
> GC> Probably. Could you show me a simple conceptual proposal, e.g., a
> GC> diff for a single file? I was thinking of doing something like:
> GC> 
> GC> -#if defined __BORLANDC__
> GC> +#if defined LMI_USE_PCH
> GC>  #   include "pchfile.hpp"
> GC>  #   pragma hdrstop
> GC> -#endif // defined __BORLANDC__
> GC> +#endif // defined LMI_USE_PCH
> GC> 
> GC> i.e. 's/__BORLANDC__/LMI_USE_PCH/' for these PCH blocks only.
>  Unfortunately this is not going to work for MSVC because the precompiled
> header inclusion must be the first non-trivial line of the file, i.e. it
> can't occur inside a preprocessor conditional.
>  Currently the code looks like this:
>       #include LMI_PCH_HEADER
>       #ifdef __BORLANDC__
>       #   pragma hdrstop
>       #endif // __BORLANDC__
> where LMI_PCH_HEADER is defined, on compiler command line, as either
> "pchfile.hpp" or "pchfile_wx.hpp" and both these files include config.hpp
> unconditionally and then include a subset of common headers inside
>       #if defined LMI_COMPILER_USES_PCH && !defined LMI_IGNORE_PCH
> check.

Then the __BORLANDC__ conditional block is ignored by every compiler we
can foresee using, and the "pragma hdrstop" directive in that block is
therefore ignored, too--so the whole block can be removed, and replaced
by a single one-line include-directive, right?

>  Many variations are, of course, possible, but to be able to use PCH with
> MSVC there must be an #include before anything else. So either all files
> should start with
>       #include "pch_if_used.hpp"
> or
>       #include "wx_pch_if_used.hpp"
> (depending on whether the file is part of GUI code or not) or the file name
> must be a macro as it is now. Do you have any preference for one or the
> other of these solutions?

(1) #include LMI_PCH_HEADER

What macro definition makes that work with gcc? I guess we'd need a
default definition that refers to an actual header--a new header that
deliberately contains nothing but comments and is never updated except
for copyright. And that default definition would have to be provided by
makefiles, because no other header can be included before LMI_PCH_HEADER,
so I like this option less than...

(2) #include "non-wx-pch-file.hpp" XOR #include "wx-pch-file.hpp"

Here, one of two PCH headers is selected in each source file. That seems
more robust than specifying it in makefiles, as two different makefiles
might specify it two different ways.

I'll plan to make this change globally, if it meets your needs:

+#include "pchfile.hpp"
+#include "pchfile_wx.hpp"
-#if defined __BORLANDC__
-#   include "pchfile.hpp"
-#   pragma hdrstop
-#endif // defined __BORLANDC__

I believe I can discern which source files need wx; if I make a mistake,
it can be fixed easily.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]