Two Choices for Precompiling Code
Either method of precompiling code—automatically or manually—stores the resulting precompiled code in a file called a precompiled header.
The easier way to precompile code is to use the automatic precompiled-header option (/YX). The /YX option causes the compiler to either create a precompiled header with a default name of MSVC.PCH or use a precompiled header named MSVC.PCH if one exists. You can also control the name of the precompiled header that is created or used with the /Fp (Specify Precompiled Header Filename) option.
The other way to precompile code is to use the manual precompiled-header options /Yc (Create Precompiled Header) and /Yu (Use Precompiled Header). Use the /Yc option to create a precompiled header. When used with the optional hdrstop pragma, /Yc lets you precompile both header files and source code. Use the /Yu option to use an existing precompiled header in the existing compilation. You can also use the /Fp option with the /Yc and /Yu options to provide an alternative name for the precompiled header.
The following sections describe the precompiled header options and #pragma hdrstop in more detail. See Using Precompiled Headers in a Project for a method for using PCH files; that section includes an example makefile and the code that it manages. For further examples using precompiled headers, see the makefiles used to build the program examples that ship with the Microsoft Foundation Class Library.