VS2017 reports an error and cannot open the source file problem solution

Problem Description:

Problem description: I created a new QT GUI project without any modification, but the error list shows that the existing file cannot be opened, and there are various red underlines under the header file of the file code, but there is no problem running main.cpp directly.

Solution:

For the existing files in the project, there is an error that cannot be opened, indicating that the path of the current project is not included. Here you can check the method of obtaining C++ header file references (C++ knowledge key). So we only need to add the current project path.
Method: Right-click the project, click properties, select the include directory to add in the VC++ directory $(ProjectDir), then apply and confirm.
Insert picture description here

principle

#include<xx.h> means to find files directly from the function library that comes with the compiler, and the compiler starts searching from the standard library path. xxh

#include"xx.h" means to find from the customized file first, if you can't find the file from the library, the compiler will search xx.h from the user's working path

If we use the <> method to quote the header file we wrote, there will inevitably be the problem of not being able to find the source file, because our file is placed in the user directory, and the above solution is essentially by appending the user directory to Within the search scope of the compiler, the problem can be solved by replacing <> with "".

Guess you like

Origin blog.csdn.net/weixin_43624728/article/details/114416269