Unions

Chapter 14 - Advanced Programming Topics

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Precompiled Header Files
Writing efficient header files is one method of speeding up the compiling of a program. Another technique is to use precompiled header files. Precompilation is most useful for compiling a stable body of code for use with another body of code that is under development.
Creating Precompiled Headers
When working in the development environment, the compiler is set, by default, to automatically use precompiled header files. To create such files, use the Project menu and select the Settings menu item. Click the mouse on the C/C++ tab and select Precompiled Headers in the Category box. You will then be able to set the Create precompiled header file (.PCH) option from this folder.
A similar action can be achieved from the command line. The compiler’s command-line option, /Yc, instructs the compiler to create a precompiled header (.PCH) file. The syntax looks like:
/Yc[yourfile]
No space is allowed between /Yc and [yourfile]. The /Yc switch causes the compiler to compile the entire source file, including any and all included header files. The precompiled file is saved with the yourfile name of the source file and a .PCH extension.
  Note Precompiled header files are often quite large. When developing multiple projects, keep an eye on how many of these files you are willing to store on your hard disk.
Using Precompiled Headers
You must follow a certain procedure to create a project that uses precompiled headers. The use of such headers in a project makefile has certain restrictions. First, there can only be one precompiled header yourfile.PCH file for each source language in the project (C and/or C++).
Second, all files for a given language must use the identical precompiled header. Additionally, each source file must include the same set of include files, in the same order, up to the include file that you specify. The same path must be specified with the include file in each source file.
The following steps ensure that a project uses precompiled headers:
  1. Start by creating a normal project, making sure that you add at least one source file to the project file list. You can specify the source file from which the .PCH file will be generated by selecting this file in the list of files visible in the FileView window.
  2. Next, choose the appropriate compiler options from the Project menu by selecting the Settings menu item and then the C/C++ tab.
At this point, select the Precompiled Header option in the Category box. Make sure the Automatic use of precompiled headers option is selected.

Books24x7.com, Inc 2000 –  


Visual C++ 6(c) The Complete Reference
Visual Studio 6: The Complete Reference
ISBN: B00007FYGA
EAN: N/A
Year: 1998
Pages: 207

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net