0
votes

I have two projects A and B. In project A, I have created a source file called Logger.cpp where I have #include "stdafx.h" in the includes part. The stdafx.h is present in the project A. In project A's properties, I have project B's header file locations in the 'Additional include directories' property. When I am trying to compile the solution in Visual Studio 2013, it gets compiled successfully, but when I try to migrate my solution to Visual Studio 2019 and compile the whole solution, or only project A, I am getting the error E1696 cannot open source file "stdafx.h" .

What I have tried:

  1. I have copied the stdafx.h file from project A to project B which results in conflicts and does not allow me to open any header file included in the stdafx.h file.
  2. I have deleted project A completely and then created a new C++ project as stdafx.h file gets created when a new project gets created.

Both the above approach does not resolve the issue.

Am I missing something here?

1

1 Answers

0
votes

According to Microsoft Docs, when you create a new project in Visual Studio, a precompiled header file named pch.h is added to the project. (In Visual Studio 2017 and earlier, the file was called stdafx.h.)

So, you could set stdafx.h in Properties->C/C++->Precompiled Header->Precompiled Header file.

enter image description here