Create Precompiled Header Option (/Yc)

The “create precompiled header” option (/Yc) instructs the compiler to create a precompiled header file that represents the state of compilation at a certain point. The syntax of this option is:

/Yc[[filename]]

Using /Yc with a Filename

If you specify a filename with the /Yc option, the compiler creates a precompiled header consisting of the state of the compilation up to and including the preprocessing of an include file with that name that is specified in your base source file.

Consider the following code:

#include <afxwin.h> // Include header for class library

#include "resource.h" // Include resource definitions

#include "myapp.h" // Include information specific to this

// application

...

When compiled with the command:

CL /YcMYAPP.H PROG.CPP

the compiler saves all the results of processing AFXWIN.H, RESOURCE.H, and MYAPP.H in a precompiled header file called MYAPP.PCH.

Using /Yc Without a Filename

If you specify the /Yc option with no filename, the resulting precompiled header saves the compilation state at the end of the base source file or, if the base file contains a hdrstop pragma, at the place where the hdrstop pragma occurs.

The resulting .PCH file has the same base name as your base source file unless you specify a different filename using the hdrstop pragma.