c++ - 如何找到 "real"错误?

标签 c++ visual-c++ compiler-errors

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

以下是错误列表,以备不时之需。

    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

最佳答案

可能是遗漏了;在一个类/结构的结束}之后。你能发布一些代码吗?

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

关于c++ - 如何找到 "real"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16928012/

相关文章:

c++ - GCC 内联汇编错误 : junk `(%ebp)+4' after expression

c++ - 如何使用cmake链接库

c++ - 错误 C2079 : 'X::x' uses undefined struct 'T'

c++ - 仅具有变量输入的自定义 sprintf(...) 样式函数

c++ - OSX + llvm/libc++ 上的内存损坏/结构重新排序

visual-c++ - 用于 outlook 插件的 VSTO 中的功能区回调方法实现

visual-c++ - C++ usrsctp 回调参数 null

r - 软件包安装错误 : compilation failed

c++ - 编译错误 c++ "was not declared in this scope" "expected type specifier"等

java - 错误 :(30, 18) 无法解析 : com. android.support :design-v7:25. 3.1