visual-c++ - VC++编译时找不到exe

标签 visual-c++ compiler-errors exe

尝试在 VS 中运行/调试我的 C++ 桌面应用程序时遇到问题。

我收到一条错误消息,告诉我找不到 DieGame.exe(在调试文件夹中)!

我还在控制台中收到许多错误(c2065),告诉我在 DieGame.cpp 文件中到处都有未声明的标识符?

有任何想法吗?

DieGame.cpp 文件:

#include "Die.h"
#include "pch.h"
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    Die die8 = createDie(8);
    cout << "Rolling a D8: ";
    for (int i = 0; i < 10; i++) {
        cout << read(die8) << " ";
        roll(die8);
}
    cout << endl;
    return 0;
}

模具.cpp 文件:
#include "pch.h"
#include "Die.h"
#include <cstdlib>

using namespace std;

int roll() {
    return rand() % 6 + 1;
}
static int randomValue(int max) {
    return rand() % max + 1;
}
Die createDie(int max) {
    Die die;
    die.max = max;
    die.value = randomValue(max);
    return die;
}
void roll(Die die) {
    die.value = randomValue(die.max);
}

int read(Die die) {
    return die.value;
}

Die.h 头文件:
#ifndef INCLUDED_DIE
#define INCLUDED_DIE

using namespace std;

int roll();
#endif 

struct Die
{
    int value;
    int max;
};

Die createDie(int max);
void roll(Die die);
int read(Die die);

最佳答案

在 Die.h Header 中,移动 #endif行到文件的末尾。

关于visual-c++ - VC++编译时找不到exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52932233/

相关文章:

c++ - 制作按钮并处理它们

c++ - .def 文件中带有 DATA 的定义的未解析外部符号

java - 在if语句中比较AssertNull

emacs - 链接时有多个定义。 collect2 : error ld returned 1 exit status

python - Windows-单击应用程序时 Pyinstaller 错误 “failed to execute script ”

c++ - vc++ 中 std::string/std::wstring 的宏是什么?

c++ - Visual Studio 中的这些 .pch 和 .ncb 文件是什么?

c++ - 命名空间 'forward' 中没有名为 'std' 的成员

c++ - 更改应用程序签名?

php - exec() 似乎不执行 .exe