...
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.
I prefer this method. It is simple, smart and makes it easy to use. Please keep it this way, or at least a setting.
...
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.
I prefer this method. It is simple, smart and makes it easy to use. Please keep it this way, or at least a setting.
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.