Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Modified & Improved wxWidgets Project Wizard

<< < (7/41) > >>

Biplab:

--- Quote from: RJP Computing on January 01, 2007, 06:51:02 pm ---
--- Quote from: Biplab on January 01, 2007, 06:08:55 am ---...
Another problem with the sample code provided by the wizard is that it doesn't add wx_pch.h file to CPP files. Rather it is forcefully included. To me it should be included in the CPP file itself.
--- End quote ---
I prefer this method. It is simple, smart and makes it easy to use. Please keep it this way, or at least a setting.

--- End quote ---


--- Quote from: RJP Computing on January 01, 2007, 06:51:02 pm ---
--- Quote from: Biplab on January 01, 2007, 06:08:55 am ---...
Another problem with the sample code provided by the wizard is that it doesn't add wx_pch.h file to CPP files. Rather it is forcefully included. To me it should be included in the CPP file itself.
--- End quote ---
I prefer this method. It is simple, smart and makes it easy to use. Please keep it this way, or at least a setting.

--- End quote ---

This will create problem with Borland Compilers. With Borland compiler, there is no command, AFAIK, to create a Precompiled header by specifying a header file. It tries to generate a precompiled header by compiling the CPP file. If the CPP file does not have a #pragma hdrstop the precompilation will not stop. Rather it will try to precompile the whole file. So if the project has many files, this will create many precompiled files.

To stop this headers, to be compiled as precompiled headers, should be added first and then the #pragna hdrstop should be there to stop it. Or one can take another approach, which wxWidgets dev team follows to compile wxWidgets. They add a dummy.cpp file to project which has some header includes only.

With GCC or MSVC, one can specify a header file to precompile and generate a precompile header first, then use the same precompiled header for the rest of the files. But with Borland this is a problem.

But one thing is for sure, pre-compiled headers save a lot of time. But the CPP file should be written in proper manner to get maximum benefit.

Just to give you an example, I am working on a project. My project has about 2700 lines of code (excluding comments and third party libs) spanning over 27 files and is dependent on TinyXml and LibHaru. The full recompilation statistics are (No create, use only, i.e. 2nd time onwards) -

+-------------+--------------+----------------+
| Compiler       | With PCH       | Without PCH     |
+-------------+--------------+----------------+
| BCC 5.5.1     |  3 sec           |  18 sec            |
| MSVC 8        |  6 sec           |  36 sec            |
+-------------+---------------+---------------+

The result may vary. Also the compilation mode is set to Create / Use Precompiled headers. So when the PCH file is created, it will take longer time. But from next time onwards, it will be super fast. Now I can compile my project within Code::Blocks using different compilers, thanks to latest modification.

I'll post the latest modification after some more tests.  :D

RJP Computing:
That all makes sense, I just don't want to loose the settings part for GCC and MSVC. If you need to add some lines to the code generated, no problem.

killerbot:
but pch can increase builds a lot also, it's interesting when using a library like wx with should remain rather static.
For example in CB sources    , with the rate of current changes, a lot of the time the builds become longer because of pch.

I think the best thing is to have a correct project wizard without pch and then add the pch capabilities.

Biplab:

--- Quote from: RJP Computing on January 02, 2007, 06:50:53 pm ---That all makes sense, I just don't want to loose the settings part for GCC and MSVC. If you need to add some lines to the code generated, no problem.

--- End quote ---

For GCC, the options remains same. You need to include wx_pch.h

For Borland 5.5.1, I have added the following compiler options.

--- Code: ----H -H=<Bin_Dir>/<Target>/<Project_Name>.csm
--- End code ---

The following lines should be present on top of every CPP file.

--- Code: ---#include "wx/wxprec.h" or #include "wx_pch.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__

--- End code ---

For MSVC 6 or 7.1, no modification has been made. So there is NO support for them.

For MSVC 8 the following compiler options have been added.

--- Code: ---/Yc"wx/wxprec.h"
/Fp"<Bin_Dir>\<Target>\<Project_Name>.pch"
--- End code ---

I have not added wx_pch.h as I've not used it in my project. But I'm trying to include wx_pch.h only. I'm stuck with some problem adding that.


--- Quote from: killerbot on January 02, 2007, 06:53:42 pm ---but pch can increase builds a lot also, it's interesting when using a library like wx with should remain rather static.
For example in CB sources    , with the rate of current changes, a lot of the time the builds become longer because of pch.

--- End quote ---

Frankly speaking I don't have enough experience with PCH. But still I'm adding them as the settings worked for me. Any suggestions, improvements are always welcome.  :)

You are right, sometimes PCH may increase the build time. But if all the CPP files are properly planned, it can really boost the performance (Please don't mean that I'm telling Code::Blocks is not properly planned  :)). What I mean to say is that if the headers, up to the point of pre-compilation, in all the CPP files in a project or a subproject is inconsistent, it will increase the build time as it will try to regenerate / create new PCH file (I faced this with Borland and to some extent with MSVC 8 ).

In my case the same project was taking about 8 sec with PCH with Borland. When I closely looked into my CPP files, I found some #pragma hdrstop are missing. I fixed them and now it takes only 3 sec!!


--- Quote from: killerbot on January 02, 2007, 06:53:42 pm ---I think the best thing is to have a correct project wizard without pch and then add the pch capabilities.

--- End quote ---

The option is always available. Earlier the Wizard used to pop-up a message saying that the PCH is available only with GCC and then proceeded without adding PCH support. Now it adds the compiler options only if you select them. Otherwise, they won't infect your project.  :)

I have few queries.

* Does Code::Blocks support PCH for compilers other than GCC?
* How is the PCH handled internally by Code::Blocks?

RJP Computing:
Great Biplab. When can I get my hands on the updated wizard code?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version