4

我在程序的错误列表中显示了大量错误,但列出的错误似乎都不是“真正的”错误。有些线条是红色的,然后当我在它们上面突出显示时,错误就会消失。我似乎无法找到我的错误到底在哪里。找出我的错误的最佳过程是什么?

以下是有帮助的错误列表。

    Error   38  error C1004: unexpected end-of-file found   85
Error   68  error C1004: unexpected end-of-file found   42
Error   63  error C1903: unable to recover from previous error(s); stopping    compilation  72
Error   66  error C2059: syntax error : ')' 42
Error   2   error C2059: syntax error : '>' 80
Error   40  error C2059: syntax error : '>' 80
Error   65  error C2059: syntax error : '>' 42
Error   20  error C2065: '_Ptr_cerr' : undeclared identifier    27
Error   16  error C2065: '_Ptr_cin' : undeclared identifier 25
Error   22  error C2065: '_Ptr_clog' : undeclared identifier    28
Error   18  error C2065: '_Ptr_cout' : undeclared identifier    26
Error   28  error C2065: '_Ptr_wcerr' : undeclared identifier   32
Error   24  error C2065: '_Ptr_wcin' : undeclared identifier    30
Error   30  error C2065: '_Ptr_wclog' : undeclared identifier   33
Error   26  error C2065: '_Ptr_wcout' : undeclared identifier   31
Error   4   error C2065: 'faction' : undeclared identifier  84
Error   42  error C2065: 'faction' : undeclared identifier  84
Error   64  error C2065: 'Faction' : undeclared identifier  42
Error   13  error C2065: 'socialite' : undeclared identifier    100
Error   51  error C2065: 'socialite' : undeclared identifier    100
Error   1   error C2065: 'Socialite' : undeclared identifier    80
Error   12  error C2065: 'Socialite' : undeclared identifier    100
Error   39  error C2065: 'Socialite' : undeclared identifier    80
Error   50  error C2065: 'Socialite' : undeclared identifier    100
Error   8   error C2065: 'textWriter' : undeclared identifier   82
Error   46  error C2065: 'textWriter' : undeclared identifier   82
Error   6   error C2143: syntax error : missing ',' before ')'  84
Error   10  error C2143: syntax error : missing ',' before ')'  82
Error   14  error C2143: syntax error : missing ',' before ')'  100
Error   44  error C2143: syntax error : missing ',' before ')'  84
Error   48  error C2143: syntax error : missing ',' before ')'  82
Error   52  error C2143: syntax error : missing ',' before ')'  100
Error   17  error C2143: syntax error : missing ',' before ';'  25
Error   19  error C2143: syntax error : missing ',' before ';'  26
Error   21  error C2143: syntax error : missing ',' before ';'  27
Error   23  error C2143: syntax error : missing ',' before ';'  28
Error   25  error C2143: syntax error : missing ',' before ';'  30
Error   27  error C2143: syntax error : missing ',' before ';'  31
Error   29  error C2143: syntax error : missing ',' before ';'  32
Error   31  error C2143: syntax error : missing ',' before ';'  33
Error   7   error C2143: syntax error : missing ';' before '{'  32
Error   15  error C2143: syntax error : missing ';' before '{'  10
Error   32  error C2143: syntax error : missing ';' before '{'  36
Error   35  error C2143: syntax error : missing ';' before '{'  27
Error   45  error C2143: syntax error : missing ';' before '{'  32
Error   54  error C2143: syntax error : missing ';' before '{'  34
Error   57  error C2143: syntax error : missing ';' before '{'  48
Error   60  error C2143: syntax error : missing ';' before '{'  61
Error   3   error C2143: syntax error : missing ';' before '}'  82
Error   11  error C2143: syntax error : missing ';' before '}'  98
Error   33  error C2143: syntax error : missing ';' before '}'  42
Error   34  error C2143: syntax error : missing ';' before '}'  45
Error   36  error C2143: syntax error : missing ';' before '}'  83
Error   37  error C2143: syntax error : missing ';' before '}'  85
Error   41  error C2143: syntax error : missing ';' before '}'  82
Error   49  error C2143: syntax error : missing ';' before '}'  98
Error   55  error C2143: syntax error : missing ';' before '}'  43
Error   58  error C2143: syntax error : missing ';' before '}'  57
Error   61  error C2143: syntax error : missing ';' before '}'  69
Error   67  error C2143: syntax error : missing ';' before '}'  42
Error   5   error C2275: 'Faction' : illegal use of this type as an expression  84
Error   43  error C2275: 'Faction' : illegal use of this type as an expression  84
Error   9   error C2275: 'std::ofstream' : illegal use of this type as an expression    82
Error   47  error C2275: 'std::ofstream' : illegal use of this type as an expression    82
Error   53  error C2653: 'Socialite' : is not a class or namespace name 33
Error   56  error C2653: 'Socialite' : is not a class or namespace name 46
Error   59  error C2653: 'Socialite' : is not a class or namespace name 60
Error   62  error C2653: 'Socialite' : is not a class or namespace name 72
4

5 回答 5

6

可能是失踪了;在类/结构的关闭 } 之后。你能发布一些代码吗?

更新:代码现在在我的 gcc 上编译。我发现的问题是您的类之间存在循环依赖关系。所以解决这个问题,在标题中前向声明其中的一些。我添加了class Faction;之前class SocialiteinSocialite.hclass Socialite;之前class Factionin Faction.h

于 2013-06-04T21:50:10.367 回答
1

文件的意外结尾通常是您缺少一个结束的“东西”,例如括号}或括号)

于 2013-06-04T21:50:41.567 回答
0

从报告的第一个错误开始。通常它是许多后续问题的原因,因为第一个错误导致解析器与其余代码不同步。

在 C++ 中,一连串的错误通常是由未声明的类型(您是否忘记了包含文件?)或;类或结构定义后的缺失引起的。

考虑:

Foobar fb;  // Declare an instance of Foobar.

如果尚未声明 Foobar(可能是因为您忘记包含“foobar.h”),那么编译器可能会认为您正在尝试声明一个名为 Foobar 且默认类型为 int 的变量。从那里,它看到 fb 并变得很困惑。

或考虑:

struct Foobar {
  int x;
  int y;
}

int blah = 0;

如果没有;after 结构定义,解析器会认为您正在尝试声明一个名为 int 的 Foobar 实例,这是不允许的,因为 int 是保留关键字。之后的一切对编译器来说都像是 gobbledegook。

一个技巧是在第一个报告错误的行之后临时#if 0删除所有代码,因为这将减少噪音,直到您隔离原始问题。

于 2013-06-04T22:04:53.637 回答
0

它要么是类型定义末尾的缺失#endif或 a ,要么可能是函数末尾的缺失。;}

于 2013-06-04T21:55:21.283 回答
0

如果您查看“错误列表”窗口(查看 > 错误列表),可能很难找出错误的来源。幸运的是,还有另一种方法:

  1. 打开“输出”窗口(调试 > 窗口 > 输出)
  2. 编译和构建
  3. 从“输出”窗口的顶部开始,沿着编译器/链接器输出文本向下工作,直到到达显示“错误”的第一行

这通常会引导你解决问题。

于 2013-06-04T23:04:44.800 回答