在另一个文件中定义函数后,Visual Studio 无法识别该函数

After defining a function in another file, visual studio does not recognize the function

本文关键字:函数 Studio 识别 Visual 文件 另一个 定义      更新时间:2023-10-16

我正在创建具有许多页面(拆分为文件(的Windows控制台应用程序。我在执行程序时遇到问题,Visual Studio抛出'startpage' identifier not found错误(startpage是函数,文件名是startpage.h(

我试过使用: external int startpage();int startpage(); .我也尝试只更改函数名称(因此文件和函数不使用相同的名称(。

我不知道为什么会这样。其他具有不同功能的文件正在工作。文件 "startpage.h" 使用其他文件中定义的两个函数,这些函数不会引发任何错误。

#include "include/startpage.h"
#include <iostream>
#include <conio.h>
#include "include/concol.h"
#include "pch.h"
#include <iostream>
using namespace std;

int main()
{
    startpage(); 
}
```

这是错误:

Error code: C3861: 'startpage' identifier not found

#include"pch.h"移到顶部。编译器忽略包含预编译标头以上的所有内容。– 伊戈尔·坦德特尼克

这奏效了!非常感谢你们!

相关文章: