/Yu - Use Precompiled Header (Windows CE 5.0)
This option instructs the compiler to use an existing precompiled header in the current compilation. There is no space between the option and the filename.
/Yu[<filename>]
The following list describes how to use /Yu with or without a file name.
Using /Yu with a File Name
The filename argument is the name of a header file that is included in the source file using an #include preprocessor directive. The include file name must be the same for both the /Yc - Create Precompiled Header option that creates the precompiled header, and any subsequent /Yu option indicating use of the precompiled header.
The compiler assumes that all code occurring before filename is precompiled. The compiler skips to the specified #include directive, uses the code contained in the precompiled header file, and then compiles all code after filename.
In addition, you can use the /Fp - Specify Precompiled Header option with the /Yu option to specify the name of the .pch file if the name is different from either the filename argument to /Yc or the base name of the source file.
The following code example shows how to use precompiled code from Myapp.pch, thereby saving the time involved in preprocessing all three of the include files and any files they might include.
#include <afxwin.h> // Include header for class library. #include "resource.h" // Include resource definitions. #include "myapp.h" // Include information specific to application.
Compile with the command line:
CL /YuMYAPP.H PROG.CPP
Note If the options /Ycfilename and /Yufilename occur on the same command line and both reference, or imply, the same filename, /Ycfilename takes precedence. This characteristic simplifies the writing of makefiles.
Using /Yu Without a File Name
When you specify the /Yu option without a file name, your source program must contain a hdrstop pragma that specifies the file name. The compiler does the following:
- Skips to the location of that pragma
- Restores the compiled state from the precompiled header file specified by the pragma
- Compiles code that follows the pragma
If the hdrstop pragma does not specify a file name, the compiler looks for a file with a name derived from the base name of the source file with a .pch extension.
If you specify the /Yu option without a file name and fail to specify a hdrstop pragma, the compiler generates an error message, and the compilation fails.
See Also
Compiler Options | /Yc - Create Precompiled Header | /Fp - Specify Precompiled Header
Send Feedback on this topic to the authors