[C++-sig] Pyste suggestion: MSVC precompiled headers support

Nicodemus nicodemus at globalite.com.br
Wed Oct 8 23:27:25 CEST 2003


Hi Niall,

Niall Douglas wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>On 7 Oct 2003 at 23:41, Nicodemus wrote:
>
>  
>
>>>I would suggest Include() for per-file includes and CommonInclude()
>>>for the cross-module includes. Then even better you can have your
>>>converter registering modules (I call mine _regconvs) generate your
>>>precompiled headers for you which saves another ten seconds :)
>>>      
>>>
>>Sorry, you will have to be a little more specific than that: I have no
>>experience with precompiled headers. 8) Also, could you tell the
>>compiler switch and how to create/use precompiled headers? Using just
>>your code didn't improve the speed at all, and didn't generate any PCH
>>file. 8(
>>    
>>
>
>Precompiled headers are really precompiled source ie; just before the 
>back end of the compiler spits out assembler. In MSVC you must use 
>special command line switches to both generate and use precompiled 
>headers - without these nothing happens.
>
>The traditional use is to tell MSVC to ignore everything prior to 
>some specified header file or #pragma hdrstop ie; therefore if pyste 
>puts an extra header file before that point, MSVC misses it 
>completely and the file won't compile.
>

I don't understand that, because:

#include <boost/python.hpp>
#include <boost/cstdint.hpp>
#ifdef _MSC_VER
#pragma hdrstop
#endif
#include <A.h>

works for me. I thought that everything before #hdrstop would be 
*included* in the pre-compiled header, not excluded. But I don't see 
that happening, the code compiles fine.

>Because pyste doesn't order its header files in a usefully 
>predictable way and order, it's very hard to set settings which 
>correctly work without some hand reordering.
>
>If you do get precompiled headers working (and once MSVC fixes the 
>bugs which mean it doesn't work properly with Boost), you can expect 
>up to a 50% speed increase.
>
>To give you some idea, with a naïve MSVC project implementation it 
>was taking me about three hours to compile. With scons and 
>precompiled headers, it's about 35 mins. That's about five or six 
>times quicker!!!
>

Thanks for the explanation. If it has so much benefits, I am very wiling 
to add support for it.

>If you could always get pyste to start off with *exactly* the same 
>#include's in the same order across all modules, then we don't need 
>this feature. I had been assuming that the mechanism I proposed was 
>easier and better extensible for the future.
>

Well, this headers are included always first:

<boost/python.hpp>
<boost/cstdint.hpp>

And I guess you could easily create a header, named "mylib.h", that 
includes everything else. So your pyste files would always just use this 
header to look for the classes/functions. Notice too that with the new 
--cache-dir option, GCCXML would be called only once for "mylib.h".
With this, I guess using pre-compiled headers would be possible, right?

Regards,
Nicodemus.





More information about the Cplusplus-sig mailing list