Q117780: Using .PCH Files Across Projects in Visual Workbench
Article: Q117780
Product(s): Microsoft C Compiler
Version(s):
Operating System(s):
Keyword(s): kbide kbVC
Last Modified: 22-JUL-2001
-------------------------------------------------------------------------------
The information in this article applies to:
- The Visual Workbench Integrated Debugger, used with:
- Microsoft Visual C++, versions 1.0, 1.5, 1.51, 1.52
- *EDITOR Please do not choose this product*Microsoft Visual C++ 32-bit Edition* use 241, 265, 225, 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:
1. 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.
2. 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.
3. For each project, choose Project from the Options menu.
4. Choose the Compiler command button to change the compiler options
5. Choose Precompiled Headers from the Category list box.
6. In the Precompile through Header edit box, enter the complete path of the
common headers.
7. Choose Debug Options from the Category list box.
8. 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.
9. Choose the "OK" button to accept these changes and then choose the "OK"
button again to close the Project Options dialog box.
10. 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
Technology : kbVCsearch kbAudDeveloper
=============================================================================
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.