Sign in to follow this  
DWN

Precompiled header

Recommended Posts

My question concerns the use of precompiled headers (.pch). Could a program drop regular header files completely? For instance, if the code says, #include "foo.h" but no "foo.h" exists, only "foo.pch" exists, will the compiler generate a failure to find the file, or will it know to use the precompiled header under Visual Studio? Thanks for any help.

Share this post


Link to post
Share on other sites
The build process will always look for every include file, because it needs to know if it should rebuild the PCH. If one is missing, it will just throw an error.

The PCH is just an optimization. Building with a PCH should have the same result as not using a PCH (it just might be faster). If a no-PCH build would fail, then the PCH-enabled build should fail in the same situation.

Share this post


Link to post
Share on other sites
Thanks for all the responses.

Pina and Oxyd, I realize I should have stated the reason I was asking. I plan to release a software library, but was thinking that I might not want all of the data in the header files to be easily readable. I'm sure there are other ways to do that, but I thought that there might be some simple method for just using a .pch.

Namethat.., I was at work, so couldn't. I would have posted anyhow, though, because it definitely would have taken me longer, I might have messed up in the process and understood things wrong, and, if someone happened to know, I thought they might not mind just telling me. Additionally, I might learn something about precompiled headers, of which I know almost nothing. There is no reason to feel the need to mystify something that should be straightforward. If you're going to berate me, you may as well tell me the answer. Sorry for my crabbiness, but I don't think my 10-second question deserves a no-reply reply. If you feel like it, you can take it out on my rating, though, seems most people have.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this