4.24 Precompiled Header (PCH) files

Precompiled Header files can help reduce compilation time when the same header file is used by multiple source files.

When you compile source files, the included header files are also compiled. If a header file is included in more than one source file, it is recompiled when each source file is compiled. Also, you might include header files that introduce many lines of code, but the primary source files that include them are relatively small. Therefore, it is often desirable to avoid recompiling a set of header files by precompiling them. These are referred to as PCH files.

By default, when the compiler creates a PCH file, it:

  • Takes the name of the primary source file and replaces the suffix with .pch.

  • Creates the file in the same directory as the primary source file.


Support for PCH processing is not available when you specify multiple source files in a single compilation. In such a case, the compiler issues an error message and aborts the compilation.


Do not assume that if a PCH file is available, it is used by the compiler. In some cases, system configuration issues mean that the compiler might not always be able to use the PCH file. Address Space Randomization on Red Hat Enterprise Linux 3 (RHE3) is one example of a possible system configuration issue.

The compiler can precompile and use PCH files automatically with the --pch option, or you can use the --create_pch and --use_pch options to manually control the use of PCH files.

Related concepts
4.25 Automatic Precompiled Header (PCH) file processing
4.26 Precompiled Header (PCH) file processing and the header stop point
4.27 Precompiled Header (PCH) file creation requirements
4.28 Compilation with multiple Precompiled Header (PCH) files
4.29 Obsolete Precompiled Header (PCH) files
4.30 Manually specifying the filename and location of a Precompiled Header (PCH) file
4.31 Selectively applying Precompiled Header (PCH) file processing
4.32 Suppressing Precompiled Header (PCH) file processing
4.33 Message output during Precompiled Header (PCH) processing
4.34 Performance issues with Precompiled Header (PCH) files
Related reference
8.146 --pch
8.147 --pch_dir=dir
8.148 --pch_messages, --no_pch_messages
8.149 --pch_verbose, --no_pch_verbose
10.85 #pragma hdrstop
10.90 #pragma no_pch
Non-ConfidentialPDF file icon PDF versionARM DUI0472J
Copyright © 2010-2013 ARM. All rights reserved.