Search code examples
visual-studiovisual-c++visual-studio-2019precompiled-headers

Error C1010 unexpected end of file while looking for precompiled header


I'm getting this error (as title says) with Visual Studio 2019. I have browsed through some other answers here (and elsewhere), but I am actually following the advice that I can find:

  • I am including pch.h in every source file, at the top of the file
  • I have this build option /Fp"..\obj\Debug-windows-x86_64\myProject\myProject.pch"
  • I have also this build option /Yu"pch.h"

Configuration Properties -> C/C++ -> Precompiled Headers has marked the header as enabled, and I have checked that the names match.

But, the precompiled header does not seem to be built (at least I cannot find it in obj/... directory), and this error persists.

I would rather not disable the precompiled header, but rather get it working properly. Any advice?


Solution

  • You need to specify /Yc (Create Precompiled Header File) for your pch.h file:

    https://learn.microsoft.com/en-us/cpp/build/reference/yc-create-precompiled-header-file?view=msvc-160