Using .PCH Files Across Projects in Visual Workbench
ID: Q117780
|
The information in this article applies to:
-
The Visual Workbench Integrated Debugger, used with:
-
Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52
-
Microsoft Visual C++ 32-bit Edition, version 1.0
SUMMARY
In some instances, it is beneficial to share precompiled header (.PCH)
files among several projects. However, the Visual Workbench is not able to
use the program database (.PDB) files, because project-specific information
related to each .PCH file is stored in the .PDB files. This article
explains how to use .PCH files without using .PDB files in the versions of
Visual C++ listed above. This same thing can be done in later versions of
Visual C++ 32-bit Edition, but the steps will be different.
MORE INFORMATION
To use a common precompiled header among different projects:
- Copy the header file into the common directory you want, and then
delete it from the individual project directories. When using
applications generated by AppWizard, the STDAFX.H file is the same for
all applications, so it is a good candidate for a shared precompiled
header.
- For each .CPP file that includes the file being used for precompiled
headers, give an explicit path to the header. For example, suppose that
the .CPP file contains the following:
#include "stdafx.h"
If the new location of the header file is C:\MSVC\CMN_HDR, then this
statement should be changed to the following:
#include "c:\msvc\cmn_hdr\stdafx.h"
Repeat this step for each project that uses a common header file.
- For each project, choose Project from the Options menu.
- Choose the Compiler command button to change the compiler options
- Choose Precompiled Headers from the Category list box.
- In the Precompile through Header edit box, enter the complete path of
the common headers.
- Choose Debug Options from the Category list box.
- Put the bullet on the Full (C7 Compatible) radio-control box. This
directs the compiler not to place any of the precompiled header
information into the .PDB file, which keeps inconsistency errors from
occurring in that file.
- Choose the "OK" button to accept these changes and then choose the "OK"
button again to close the Project Options dialog box.
- For each project, choose Scan All Dependencies from the Project menu
before rebuilding the project so that the compiler will use the new
common header file.
Additional query words:
kbinf 1.00 1.10 1.50
Keywords : kbide kbVC
Version :
Platform : NT WINDOWS
Issue type :
|