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

C++ Compile errors on lines that don't exsist. How to make restart function

本文关键字:何使 重启 功能 编译 不存在 C++ 错误      更新时间:2023-10-16

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

#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行等等。我正在使用自定义版本的visual c++编译器。

还有更多,但从错误的数量来判断,似乎我一直在做重启功能错误。有人知道正确的方法来做一个重启函数和停止函数的代码?我是c++的新手,所以我不太习惯语法。

if语句中缺少')',第一行只是注释;)