Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a reason for which one should not add all the imports inside .pch file?

I'm mainly refering to application-level imports, not when you build a library, in which case is obvious why you should avoid importing the headers inside the .pch file.

like image 915
Meda Avatar asked Nov 22 '25 19:11

Meda


1 Answers

The point of the .pch file is that it can be precompiled once and left alone.

If you import all of your application headers in the .pch, it has to be recompiled every time you change any one of those headers, negating all of the benefits. Worse yet, this ends up meaning that every other file in your project has to be rebuilt, because the contents of the .pch changed.

The only headers that should be pulled in by your .pch are headers that'll almost never change, like system headers.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!