Short story:
I can\'t make precompiled headers work properly with gcc -c option.
Long story:
Folks, I\'m using gcc-4.4.1 on Linux and before trying preco
Ok, I think I've found the solution: -fpch-preprocess should be used alongside with -c option. It works like a charm!
Here's the timings:
with pch
$ time g++ -I. -include pre.h -c foo.cpp -fpch-preprocess
real 0m0.028s
user 0m0.016s
sys 0m0.016s
without pch
$ time g++ -I. -c foo.cpp
real 0m0.330s
user 0m0.292s
sys 0m0.044s
Update: I asked the same question on the gcc help mailing list and Ian Lance Taylor explained this strange behavior by my usage of distcc/ccache. These tools first preprocess the source that's why this options is required.