首页 > 解决方案 > VC++编译时找不到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);

标签: visual-c++compiler-errorsexe

解决方案


In Die.h Header, move the #endif line to the end of the file.


推荐阅读