Visual Studio在调试代码时跳过头文件

Visual Studio is skipping the header files while debugging the code

本文关键字:文件 代码 Studio 调试 Visual      更新时间:2023-10-16

我正在尝试使用opencv运行面部检测程序。我已经正确地在属性中包含opencv库的路径,但程序仍然给出错误,未能构建可执行文件并在调试期间跳过头文件,并给出这些消息:

1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.avi2.cpp(241) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Build log was saved at "file://c:UsersAbdullahDocumentsVisual Studio 2008Projectsavi2avi2ReleaseBuildLog.htm"
1>avi2 - 1 error(s), 10 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

avi2.cpp配置为使用预编译头文件。为了使这个特性工作,编译器期望第一个非空白/非注释行代码是#include "stdafx.h"。它不在那里,所以你会得到这个错误。

要解决这个问题,您可以禁用预编译头为.cpp文件错误,或添加#include使其工作

您的项目设置为使用预编译头文件,但您还没有提供一个。项目中的每个文件都应该将#include "stdafx.h"作为第一行。

所以,取决于你是否想要使用它们,要么添加包含,要么将项目设置更改为'不使用预编译头'

如果使用预编译头文件,每个cpp文件的第一个非注释行必须是#include "stdafx.h"之前的所有行都被忽略

必须是第一个 include。

查看来自Microsoft的KB