Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

FatalXC

Precompiled Headers

This topic is 6198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Could someone explain how/why these are useful, and what sort of things to put in stdafx.h? How do you add a PCH to a current project? Thanks, Richard

Share this post


Link to post
Share on other sites
Advertisement
The main benefit of using PCH files is to reduce compilation time. In large projects (hundereds of files), PCH files can cut 30% off of build times.

However, in my experience they can not always be trusted. Many of the nastiest and most ellusive bugs that I''ve come across have been caused by PCH files not being updated correctly.

Adding PCH files to existing projects is as simple as including the header files, and changing the project properties to use pre-compiled headers.

stdafx.h should only include files that you use in every file (or almost every file), maybe for example.

Share this post


Link to post
Share on other sites
In my project though, there are very few files that are always included, in many not even windows.h is included, so are PCHs going to be of no use in this situation?

Extra causes of bugs sounds raher unappealing.

Thanks,

Richard

Share this post


Link to post
Share on other sites
the only benefit is compilation time (and disk space consumption

I''d recommend only putting standard includes in the pch to avoid the mentioned bugs and to avoid rebuilding it as you change your headers. And then only use it if you are using big fat headers like windows.h



~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Community Service Announcement: Read How to ask questions the smart way before posting!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!