# hdrstop

Visual Studio 2010

Gives you additional control over precompilation file names and over the location at which the compilation state is saved.

```#pragma hdrstop [( "filename" )]
```

## Remarks

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.

If a C or C++ file contains a hdrstop pragma when compiled with /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.

Use filename to name the precompiled header file in which the compiled state is saved. A space between hdrstop and filename is optional. The file name 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 and use the escape character (backslash) to specify directory names. For 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 #pragma hdrstop

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

For the /Yc and /Yu options, if neither of the two compilation options nor the hdrstop pragma specifies a file name, the base name of the source file is used as the base name of the precompiled header file.

You can also use preprocessing commands to perform macro replacement as follows:

```#define INCLUDE_PATH "c:\\progra~`1\\devstsu~1\\vc\\include\\"
#define PCH_FNAME "PROG.PCH"
.
.
.
#pragma hdrstop( INCLUDE_PATH PCH_FNAME )
```

The following rules govern where the hdrstop pragma can be placed:

• It must appear outside any data or function declaration or definition.

• It must be specified in the source file, not within a header file.

## Example

```#include <windows.h>                 // Include several files
#include "myhdr.h"

__inline Disp( char *szToDisplay )   // Define an inline function
{
...                              // Some code to display string
}
#pragma hdrstop
```

In this example, the hdrstop pragma appears after two files have been included and an inline function has been defined. This might, at first, seem to be an odd placement for the pragma. Consider, however, that using the manual precompilation options, /Yc and /Yu, with the hdrstop pragma makes it possible for you to precompile entire source files — even inline code. The Microsoft compiler does not limit you to precompiling only data declarations.
{"extraction_info": {"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8467392325401306, "perplexity": 5220.457653286667}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-44/segments/1476988719045.47/warc/CC-MAIN-20161020183839-00081-ip-10-171-6-4.ec2.internal.warc.gz"}