The /Yc (Create Precompiled Header) Option
The /Yc (Create Precompiled Header) option 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:
/Ycfilename
Using /Yc with a Filename
If you specify a filename with the /Yc option, the compiler precompiles all code up to and including the specified file. The precompiled code is saved in a file with a name created from the base name of the file specified with the /Yc option and a .PCH extension. You can also use the /Fp option, described in The /Fp (Specify Precompiled Header Filename) Option, to specify a name for the resulting precompiled header 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 or the /Fp option.
Note If the /Ycfilename and /Yufilename options occur on the same command line and both reference the same filename, /Ycfilename takes precedence, precompiling all code up to and including the named file. This feature simplifies the writing of makefiles.