VC ++编译时找不到exe

时间:2018-10-22 14:54:13

标签: 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;
}

Die.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);

1 个答案:

答案 0 :(得分:0)

在Die.h标头中,将#endif行移动到文件末尾。