.PCH

PCH File

Precompiled Header File
Ask a question
QUICK ANSWER

A PCH file is a Precompiled Header - a binary cache generated automatically by a C++ compiler (Visual Studio, Clang, or Xcode) to speed up builds by saving the parsed state of large header files. You never open or create one manually. If you see a PCH-related build error, do a Clean Build and rebuild the project.

Developer: Microsoft (MSVC); also Clang/LLVM and GCC (each with proprietary binary format) Category: Developer Files MIME: application/octet-stream
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Sep 5, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the PCH file format?

A .pch file is a precompiled header - a binary compiler cache generated automatically during the build process. Rather than re-parsing large header files such as the Windows SDK or stdafx.h on every compilation unit, the compiler serializes its internal state - symbol tables, AST nodes, macro definitions, include-guard flags - into a .pch snapshot. Subsequent compilation units load that snapshot directly, cutting build times dramatically for large C and C++ projects.

MSVC produces .pch files via the /Yc compiler flag, typically from a dedicated stub source file named pch.cpp or stdafx.cpp. Clang stores its precompiled headers as a compressed LLVM bitstream embedded inside a native object file in a section named __clangast. GCC's equivalent uses the .gch extension rather than .pch.

The format is entirely compiler-internal - proprietary, binary, and non-transferable between machines. A .pch file is invalidated whenever the compiler version, compiler flags, or any included header changes; the build system regenerates it automatically. Typical sizes range from 10 MB to over 200 MB when the Windows SDK headers are included.

Users never create or open .pch files manually. Deleting one is safe - the next build recreates it, and a clean rebuild is the standard remedy for persistent PCH-related errors. C++20 Modules partially reduce reliance on precompiled headers in new codebases, but .pch remains the dominant compile-speed mechanism in existing C and C++ projects.

Security & safety

RISK: LOW

A .pch is an internal compiler build artifact. It cannot run code and is not executed by the OS. No meaningful attack vector; the file is generated locally by the build system and is machine-specific.

Format details

in a nutshell
FULL NAMEPrecompiled Header Fileaka PCH file, precompiled header
DEVELOPERMicrosoft (MSVC); also Clang/LLVM and GCC (each with proprietary binary format)since 1988 (Microsoft C Compiler 6.0 for MS-DOS, first PCH implementation); mainstream adoption with MSVC for Windows in the 1990s
MIME TYPEapplication/octet-stream
TYPEBinary compiler cache (serialized compiler AST/symbol state)
This extension is also used by…
  • Apple Xcode Prefix Header - Xcode (pre-Swift) used a .pch prefix header (source file, not binary) to precompile Objective-C headers; the concept is the same but the file is a text header, not the binary output.

Programs that open PCH files

Windows2 apps
Microsoft Visual Studio Freemium Visual Studio creates and uses .pch automatically when building C/C++ projects. If PCH errors occur: Build > Clean Solution, then Rebuild Solution. Do not open the .pch file directly - it is a binary build artifact.
Visual Studio Code + C/C++ Extension Open-source Clang or MSVC toolchain handles PCH generation during build; not opened manually.
macOS1 app
Apple Xcode Free Xcode uses .pch for prefix headers (text source) and generates binary PCH caches internally. Clean build (Product > Clean Build Folder) resolves PCH errors.
Linux2 apps
GCC (command line) Open-source GCC generates .gch files (not .pch) for precompiled headers. Note: GCC PCH output extension is .gch, not .pch.
Clang (command line) Open-source clang -x c++-header header.h -o header.pch generates a PCH; clang -include-pch header.pch uses it.

Technical details

deep spec
File typeBinary compiler cache (serialized AST and symbol state)
EncodingBinary (compiler-internal representation)
Byte orderLittle-endian (MSVC on x86/x64); target-dependent (Clang)
ContainerProprietary binary blob (MSVC); COFF/ELF/Mach-O object file with embedded __clangast section (Clang)
CompressionNone (MSVC); compressed LLVM bitstream, zlib-based (Clang)
Typical size10 MB - 200 MB; Windows SDK PCH commonly 50-200 MB
MSVC generation flag/Yc creates the PCH; /Yu consumes it in subsequent compilation units
Default source filestdafx.cpp or pch.cpp in MSVC projects
Machine specificityNot transferable between machines; MSVC PCH includes host-specific address information
InvalidationAutomatically regenerated when compiler version, flags, or any included header changes
GCC equivalent.gch extension (GCC precompiled headers do not use .pch)
Version detectionMSVC embeds internal signature; rejects stale PCH files on version or flag mismatch
C++20 successorC++20 Modules (.ifc in MSVC) partially replace PCH in new codebases
Associated OSWindows (MSVC), macOS (Xcode and Clang), Linux (Clang and GCC)
Released1988 (Microsoft C Compiler 6.0 for MS-DOS, first PCH implementation); mainstream adoption with MSVC for Windows in the 1990s
Latest versionN/A - format is internal per compiler; MSVC PCH is regenerated by each compiler version
Specificationlearn.microsoft.com

Community Q&A

asked by users
Ask a quick question
Get help from people who work with PCH files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about PCH files.

Frequently asked questions

What is a .pch file and can I delete it?
It is a Precompiled Header - a binary cache created by your C++ compiler to speed up builds. You can safely delete it; the compiler will regenerate it on the next build (which will be slower that one time).
Why am I getting errors about a .pch file?
Most commonly the PCH is stale - mismatched compiler version or changed build flags. Fix: do a Clean Build (Build > Clean Solution in Visual Studio, then Rebuild).
Should I commit .pch files to source control?
No. They are machine-specific binary build artifacts and can be hundreds of MB. Add *.pch to .gitignore.
How do I open a .pch file?
You don't - it's a binary compiler cache with no human-readable content. If you want to inspect precompiled header contents, look at the source .h file it was generated from (stdafx.h or pch.h in Visual Studio projects).
Is .pch only used by Visual Studio?
Visual Studio is the primary user of the .pch extension. Clang also creates PCH files with a .pch extension. GCC uses .gch instead. Each compiler's format is incompatible with the others.

References

1Microsoft Learn - Creating Precompiled Header Files (MSVC)learn.microsoft.com
2GCC - Precompiled Headersgcc.gnu.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.RPMSGRestricted Permission Message
6.MDMarkdown Document
7.NOMEDIAAndroid No-Media Marker File
8.PRO6XProPresenter 6 Bundle File
9.PRDXSoftMaker Presentations Document
10.EXEWindows Executable (Portable Executable)

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z