Click here to Skip to main content
15,887,454 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
Hi,

When we create any C++ project in Visual Studio, by default it create StdAfx.h which is known as 'precompiled header'. I have gone many pages on Google, but didn't exactly understand it's usage. Can you please provide some light on it.

Regards
Posted

1 solution

Precompiled headers are used to reduce the compile time by adding often required include files there.
See Google or this Wikipedia link:
http://en.wikipedia.org/wiki/Precompiled_header[^]
I would recommend, that you add the include files that most of your other application code requires to the stdafx.h. This significantly reduces the time to build your project.
 
Share this answer
 
v2
Comments
[no name] 30-May-12 0:42am    
I have read this link.. but I wanted to know how will I use (take benefit) of this file
JF2015 30-May-12 0:47am    
So, as I wrote: Enable "Precompiled Header" in your Project settings and add the most common header files to the stdafx.h. See this MSDN docu:
http://msdn.microsoft.com/en-us/library/szfdksca%28v=vs.71%29.aspx
I also recommend to try that out with a small project, since when applying this to a huge project, you can easily mess up your build.
[no name] 30-May-12 0:52am    
Ok Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900