INFO: AppWizard and Precompiled Header FilesLast reviewed: October 3, 1997Article ID: Q119329 |
The information in this article applies to:
SUMMARYWhen you use AppWizard to generate a starter application, it sets up your project to use a precompiled header (.PCH) file. Precompiled headers help to speed up compilation when a group of files in a project do not change. In the case of Microsoft Foundation Class (MFC) applications generated by AppWizard, the group of files that do not change are the standard MFC header files. AppWizard puts the line "#include 'stdafx.h'" as one of the first lines in every .CPP file in a project. Because of the compiler options being used by projects generated with AppWizard, anything up to and including "stdafx.h" in a .CPP file is considered by the compiler to be part of a precompiled header. The problem with this is that when you edit the .CPP files and insert #includes, #defines, declarations, or other code before the "#include 'stdafx.h'" line, all of it is ignored by the compiler. This is the correctbehavior because when the compiler is using the precompiled header, it starts to compile the code in the .CPP file after skipping past the "stdafx.h" line. This behavior can lead to compiler errors that do not seem to make sense, because it appears that you are including all the needed declarations and header files in the .CPP file. For example, some of the errors that may result are the following:
REFERENCES"Visual C++ for Windows Programming Techniques" manual, chapter 1, "Using Precompiled Headers." "Visual C++ for Windows NT Programming Techniques" manual, chapter 10, "Using Precompiled Headers." Visual C++ Books Online topic "Using Precompiled Headers" in the "Visual C++ User's Guide" chapter on "Working With Projects."
|
Additional query words: random incorrect
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |