Precompiled Headers Command Line Options for BCC32

From RAD Studio
Jump to: navigation, search

Go Up to BCC32.EXE, the C++ 32-bit Command-Line Compiler

Precompiled header files can dramatically increase compilation speed by storing an image of the symbol table on disk in a file, then later reloading that file from disk instead of parsing all the header files again. Directly loading the symbol table from disk is much faster than parsing the text of header files, especially if several source files include the same header file.

To use precompiled header files on the command line, specify the various -H options in your BCC32 command.

Precompiled Header Options:

Compiler Option Description Details

Generate and use

When you enable this option, the compiler generates and uses precompiled headers. The default file name for the generated precompiled header is BC32DEF.CSM for the command-line compiler.

To specify a precompiled header, use:


To enable the precompiled header for a specific source file, use:

-H File2.cpp

Use but do not generate

When you enable this option, the compiler uses preexisting precompiled header files; new precompiled header files are not generated.


Do not generate or use

When you enable this option, the compiler does not generate or use precompiled headers. Default = Do not generate or use (-H-)


Cache precompiled headers

When you enable this option, the compiler caches the precompiled headers it generates. This is useful when you are precompiling more than one header file. To use this option, you must also enable the Generate and Use (-H) precompiled header option. Default = Off.


Generate external type files (precompiled headers)

When you enable this option, the compiler generates a file or files that contain debug type information for all the symbols contained in the precompiled headers. The filenames end with .#xx extension, where xx is 00 for the first file generated and is incremented for each additional type-information file required. Using this option dramatically decreases the size of your .OBJ files, because debug type information is centralized and is not duplicated in each .OBJ file. Default = On.


Precompiled header filename

Use this option to specify the name of your precompiled header file. When you set this option, the compiler generates and uses the precompiled header file that you specify.




Stop precompiling after header file option

This option terminates compiling the precompiled header after processing the file specified as xxx. You can use this option to reduce the disk space required for precompiled headers.

The -Hh syntax is generally easier to use than the -H syntax. Examples:

-Hh="C:\Program Files\myhdrfile.h" 
-H\"C:\Program Files\myhdrfile.h\"
  • When you use this option, the file you specify must be included from a source file for the compiler to generate a precompiled header file.
  • You can also use #pragma hdrstop in your source file to specify when to stop the generation of precompiled headers.
  • You cannot specify a header file that is included from another header file. For example, you cannot list a header included by windows.h because doing this would cause the precompiled header file to be closed before the compilation of windows.h was completed.
-Hi myhdrfile.h

Inject the contents of header file

When you specify this option, BCC32 includes the contents of the specified header file, and includes the specified header file first.

Combining -Hh and -Hi is equivalent to adding the following directives at the beginning of each .cpp file:

 #include "myhdrfile.h"
 #pragma hdrstop

See Also