Share via


Placement of the hdrstop Pragma

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 base file, not within a header file.

Consider the following 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.