C++ Precompiled Header File (*.pch)

From RAD Studio
Jump to: navigation, search

Go Up to File Types Index


When you build a C++ project, RAD Studio generates a precompiled header file.

Precompiled header files are an intermediate form of the header files of your project that is faster to process for the compiler. They enable rapid compiling.

The file name of your precompiled header file is:

  • <project>.pch for 32-bit Windows and Mac OS X.
  • <project>PCH1.pch for other platforms.

When you build your project, your C++ precompiled header file is generated into C:\Users\<user>\Documents\Embarcadero\Studio\Projects\<project>\<platform>\<build configuration>.
In platforms other than 32-bit Windows and Mac OS X, RAD Studio also generates a static version of your C++ precompiled header file within the staticobjs subfolder of the output folder of your C++ precompiled header file (C:\Users\<user>\Documents\Embarcadero\Studio\Projects\<project>\<platform>\<build configuration>\staticobjects by default).

To change the output file path in 32-bit Windows or Mac OS X, use the PCH Filename option in Project > Options > C++ Compiler > Pre-compiled headers.
You cannot change the output file name in other platforms. To change the output directory in other platforms, use the Object file output directory option in Project > Options > C++ Compiler > Directories and Conditionals.

To disable the generation of this optional file, use any of the following values for the PCH usage option in Project > Options > C++ Compiler > Precompiled headers:

  • Do not use
  • Use but don't generate

Keeping a C++ Precompiled Header File Under Version Control

If you decide to keep your C++ precompiled header file under version control, after you generate the initial version of your C++ precompiled header file remember to configure RAD Studio to use your C++ precompiled header file but to not regenerate the file. Select Project > Options > C++ Compiler > Precompiled headers, and set "Use but don't generate" as the value of the PCH usage option.

See Also