Share via


/YX - Automate Precompiled Header

This option instructs the compiler to use a precompiled header file with a default name of Msvc.pch, if one exists or, if none exists, to create one. The compiler creates file in the current directory. You can use the /Fp - Specify Precompiled Header option to change the default name and placement of the precompiled header.

The following command line example uses /YX to create or use a precompiled header named Msvc.pch.

CLARM /YX MYPROG.CPP

Using the /YX option limits precompilation to header files only. The precompiled header is created when the compiler encounters the first declaration, definition, hrdstop pragma, or #line directive that occurs in the source file. In a subsequent compilation, the compiler uses the precompiled header at the point in a source file where the compiler makes its final consistency check.

The set of header files precompiled with /YX is determined by the compiler, which may elect to use a subset of header files available to try and improve the number of cases where the resulting precompiled header can be used.

Although it is usually best to let the compiler determine which header files to use, you can selectively pre-compile header files by placing a hdrstop pragma in the source file between two #include directives. All header files before the hdrstop pragma are precompiled; those after are not. When used with /YX, any file name specified with the hdrstop pragma is ignored. If any subsequent compilation using the precompiled header does not contain an identical hdrstop pragma at the same point in the source file, the compiler builds a new precompiled header.

The /YX option implies use of the /Yd - Duplicate Debugging Info option. If /Yc - Create Precompiled Header or /Yu - Use Precompiled Header is specified with /YX, the compiler issues a warning and ignores /YX, giving precedence to /Yc or /Yu takes precedence.

See Also

Consistency Rules for the /YX Option | /Fp - Specify Precompiled Header | /Yd - Duplicate Debugging Info | /Yc - Create Precompiled Header | /Yu - Use Precompiled Header

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.