问题
When using precompiled headers, does it make a difference (or has a bad effect) when I include a header, which I already have included in the precompiled header, also in a regular header?
Or in other words: when I include a header x in another header file and at the same time include x in my precompiled header file, does this prevent the optimization provided by precompiled header to kick in?
回答1:
No
(In general). What's going to happen is that, during compilation, if you're using precompiled headers, and the compiler spots a header that is already present in the precompiled form, it will opt to use the precompiled form.
In fact, it's good practice to continue using your includes as if you never had precompiled headers on in the first place. This helps in case you turn off precompiled headers in the future or modify the list of headers in it, or someone else decides to do their own out-of-source build that doesn't use PCH.
来源:https://stackoverflow.com/questions/41614024/precompiled-headers-and-normal-includes