Share via


hdrstop

#pragma hdrstop [("filename")

Controls the way precompiled headers work. The filename is the name of the precompiled header file to use or create (depending on whether /Yu or /Yc is specified). If filename does not contain a path specification, the precompiled header file is assumed to be in the same directory as the source file. Any filename is ignored when /YX, the automatic precompiled header option, is specified.

If a C or C++ file contains a hdrstop pragma when compiled with either /YX or /Yc, the compiler saves the state of the compilation up to the location of the pragma. The compiled state of any code that follows the pragma is not saved.

The hdrstop pragma cannot occur inside a header file. It must occur in the source file at the file level; that is, it cannot occur within any data or function declaration or definition.

Note   The hdrstop pragma is ignored unless either the /YX option is specified or the /Yu or /Yc option is specified without a filename.

Use filename to name the precompiled header file in which the compiled state is saved. A space between hdrstop and filename is optional. The filename specified in the hdrstop pragma is a string and is therefore subject to the constraints of any C or C++ string. In particular, you must enclose it in quotation marks as shown in the following example:

#pragma hdrstop( "c:\projects\include\myinc.pch" )

The name of the precompiled header file is determined according to the following rules, in order of precedence:

  1. The argument to the /Fp compiler option

  2. The filename argument to #pragmahdrstop

  3. The base name of the source file with a .PCH extension