MSVC build errors > C1010
C1010: unexpected end of file while looking for precompiled header
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
The project uses a precompiled header, and this file never includes it.
Causes and fixes
- The file does not include the precompiled header. Add
#include "pch.h", orstdafx.hin older projects, as the first line of the file. - The file should not use it. For C files and third-party sources, set C/C++ > Precompiled Headers > Precompiled Header to Not Using Precompiled Headers in that file's properties.
- The name does not match the setting. The include must name the file set in Precompiled Header File, exactly.
Fix C1010 with CppPilot
CppPilot reads the error, your code, and the project settings Visual Studio evaluates for the active configuration, then explains which of these causes applies. Choose Fix and the AI corrects it; CppPilot rebuilds the project and checks that the error is gone. Every change appears in Visual Studio for your approval.
Let the AI fix it in Visual Studio
CppPilot is a free extension that explains and fixes MSVC build errors with Codex, Claude, or CppPilot Cloud.
Related errors: C2065. See all guides.