Borland Online And The Cobb Group Present:


August, 1995 - Vol. 2 No. 8

Limiting the precompiled header file

In the accompanying article, Optimizing the IDE - Saving disk space by using common precompiled header files, we mention that you'll probably want to exclude the header files for specific projects from the precompiled header file (CSM file). There are two ways you can accomplish this.

First, you can use the technique we used in the accompanying article: Enter the header filename in the Stop Precompiling After Header File entry field, which you'll find on the Precompiled Header page of the Project Options dialog box. The file- name represents the last file you want the compiler to include in the CSM file.

When you specify this file, you'll need to make sure that you name a file that is itself part of an #include directive in a source file. If you name a file that doesn't appear in a source file's #include directive, the compiler won't generate a CSM file at all. This is true even if the file you name appears in an #include directive that's inside a header file whose name does appear in a source file, as shown in Figure A.

Figure A - If you specify a header file for the compiler to use as the last file in the CSM file, it must appear in a source file's #include directives. You can use stdlib.h to stop building the CSM file here...

Figure B - ...but not here.

The second way you can control the contents of the CSM file is to add a #pragma hdrstop directive after the name of the last file you want to appear in the CSM file. The #pragma directives are compiler-specific instructions, and the hdrstop option tells the compiler to quit building the CSM file at that point.

Specifying the last header file using the #pragma hdrstop directive has an advantage over using the Project Options dialog box setting: It's portable between the command-line compiler and the Integrated Development Environment, as well as to other projects. In other words, once you've specified the stopping point, you can use that file in other projects, and the compiler will automatically stop building the CSM file at the same location.

Return to the Borland C++ Developer's Journal index

Subscribe to the Borland C++ Developer's Journal


Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.