C ++在不存在的行上编译错误。如何重启功能

时间:2016-09-28 01:15:45

标签: c++ c++11 visual-c++ restart

当我编译这段代码时,我得到编译错误:代码下面的错误。

#include <iostream>

using namespace std;
int main() 
{
    while (true) 
    {
        int go_again;
        go_again = 0;
        //[CODE HERE STARTS THREADS] Removed because it was unnecessary

        while (true) 
        {
            if ((GetAsyncKeyState(Settings()->exit_key)) // exits programm
            {
                go_again = 1;
                exit(0);
            }
            if ((GetAsyncKeyState(Settings()->restart)) // restarts programm
            {
                exit(0);
            }
            else
            {
                Sleep(100);
            }
        }
        if (go_again == 1)
        {
            exit(0);
        }
    }
    return 0;
}

以下是一些错误:

main.cpp(323) : Empty Attribute block is not allowed.
main.cpp(323) : Syntax error: Missing ']' before /
main.cpp(323) : Empty Attribute block is not allowed.
main.cpp(468) : Sytax error: missing ']' before '/'.
main.cpp(468) : Sytax error: missing ';' before '/'.
main.cpp(468) : Sytax error: missing ';' before '{'.
编辑:关于错误的另一个奇怪的事情是它说它不存在的行,因为只有100行代码,但这说错误是在线468等。我使用的是自定义版本的视觉c ++编译器。

还有更多,但从错误数量来判断,我一直在做重启功能错误。有谁知道为代码执行重启功能和停止功能的正确方法?我是C ++的新手,所以我不习惯语法。

1 个答案:

答案 0 :(得分:3)

缺少&#39;)&#39;在你的if语句中,排成一行评论;)