gcc precompiled headers weird behaviour with -c option

 ̄綄美尐妖づ 提交于 2019-12-03 04:53:13

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!