Microsoft KB Archive/117780

= Using .PCH Files Across Projects in Visual Workbench =

Article ID: 117780

Article Last Modified on 12/2/2003

-

APPLIES TO

 The Visual Workbench Integrated Debugger, when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.52 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q117780

<div class="summary_section">

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.

<div class="moreinformation_section">

MORE INFORMATION
To use a common precompiled header among different projects:

<ol> 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.</li>  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. </li> For each project, choose Project from the Options menu.</li> Choose the Compiler command button to change the compiler options</li> Choose Precompiled Headers from the Category list box.</li> In the Precompile through Header edit box, enter the complete path of the common headers.</li> Choose Debug Options from the Category list box.</li> 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.</li> Choose the "OK" button to accept these changes and then choose the "OK" button again to close the Project Options dialog box.</li> 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.</li></ol>

Additional query words: kbinf 1.00 1.10 1.50

Keywords: kbide KB117780

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.