/Yc[filename]
This option instructs the compiler to create a precompiled header (.pch) file that represents the state of compilation at a certain point.
Command line | Project settings | Description |
---|---|---|
/Yc | Create Precompiled Header File | The compiler compiles all code up to the end of the base source file, or to the point in the base file where a #pragma hdrstop 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. |
/Ycfilename | Through Header | The compiler compiles all code up to and including the .h file specified in the Through Header text box (filename). |
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 to specify a name for the precompiled header file.
If you use /Ycfilename (Through Header), the compiler compiles all code up to and including the specified file for subsequent use with the /Yu option.
Note If the options /Ycfilename and /Yufilename occur on the same command line and both reference, or imply, the same file name, /Ycfilename, takes precedence. This feature simplifies the writing of makefiles.
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 app ...
When this code is compiled with the command
CL /YcMYAPP.H PROG.CPP
the compiler saves all the preprocessing for AFXWIN.h, RESOURCE.h, and MYAPP.h in a precompiled header file called MYAPP.pch.
Compiler Options | Setting Compiler Options | Precompiled Header Compiler Options | Creating Precompiled Header Files