The PCH support is currently for GCC, but at the future it might (should) support all compilers that support PCHs. So, I guess, this "-include" won't work for all compilers...
No it won't work for all, but there is a good reason why I suggested that. Most compilers don't need precompiled headers, to be honest. It is mostly gcc that turns from "painful" to "hey, quite ok".
Takeshimiya keeps suggesting DM for its compilation speed, as you know. When I remarked that gcc is not so painful with precompiled headers at all, he replied:
As for precompiler headers, there are a lot of people that doesn't know how to use them, or don't want to (for the side effects).
You know I do not share his opinion at all regarding compilers, I think being able to compile Code::Blocks with gcc alone will do just fine for almost everybody (we are ONLY talking about compiling Code::Blocks!), and will cause the least problems (keep the code free of #ifdef
s, thus better readable).
However, I must admit that he has a very valid point nevertheless. What if someone does not want precompiled headers or does not understand them...
Compiling Code::Blocks with a non
includes 20-30 times as many include files as before - takes about 40 minutes on my machine. If you change a header and you have no clue (unless the IDE is precomp-aware), you will wonder for hours why it does not work. This can be quite a dealbreaker.
solution has the advantage that it is a "pluggable" solution. It does not change anything. If you want to use precompiled headers, fine, and if you dont want to, it is fine, too.
The "final" solution which I was thinking of in my other post was something like this:
- on request, have a plugin create a precompXXX.h file for every target (scan .cpp files in project)
- put the commandline in a comment on top
- compile that, evaluate errors (yes, you cannot precompile everything)
- comment out the includes that cause trouble
- attach the -include
flag to every target (with the respective file)
- on next run, check file modification for changed files, ignore the ones that are commented
- if options have changed, recompile the whole thing
That could actually be done inside the compilergcc plugin, too... as part of the actual compile.
Pretty good having in mind I remove the -g and change it to -O3 -s.
And here's the gotcha... changing options disables the precompiled header. (Edit: not all options do, but many, and it is not a trivial matter which do)
This is why I think this should absolutely be automated somehow, else there will be a lot of grief sooner or later - not everybody is aware of this. People will run the batch file and change options the other day, and will wonder why it suddenly takes an hour to build.