Archive for March, 2010

gcc precompiled headers weird behaviour with -c option

Sunday, March 28th, 2010

Short story

Use -fpch-preprocess option alongside with -c option in order to make precompiled headers work properly.

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.

Long story

I’m using gcc-4.4.1 on Linux and before trying precompiled headers in a really large project I decided to test them on a simple program. They “kinda work” but I was not happy with results and I was sure there was something wrong about my setup.
(more…)