C++ 致命错误 C1004:发现意外的文件结尾

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9978549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 13:28:26  来源:igfitidea点击:

fatal error C1004: unexpected end-of-file found

c++visual-c++

提问by mezamorphic

I get the above error message (which I googled and found is something to do with a missing curly brace or something), however, I cannot see where this missing bracket is?

我收到了上面的错误消息(我用谷歌搜索并发现它与缺少大括号或其他东西有关),但是,我看不到缺少的括号在哪里?

#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using namespace std;

    class Something{


        static DWORD WINAPI thread_func(LPVOID lpParameter)
        {
            thread_data *td = (thread_data*)lpParameter;
            cout << "thread with id = " << td->m_id << endl;
            return 0;
        }


        int main()
        {
            for (int i=0; i< 10; i++)
            {
                CreateThread(NULL, 0, thread_func, new thread_data(i) , 0, 0);
            }

            int a;

            cin >> a;
        }

        struct thread_data
        {
            int m_id;
            thread_data(int id) : m_id(id) {}
        };

    }

回答by Frédéric Hamidi

In C++, the classkeyword requires a semicolon after the closing brace:

在 C++ 中,class关键字需要在右大括号后加一个分号:

class Something {

};  // <-- This semicolon character is missing in your code sample.

回答by Konrad

Your class Somethingneeds to have a terminating semicolon.

你的类Something需要有一个终止分号。

class Something{

}; // missing

回答by Attila

You need a semicolon (;) after the closing brace (}) of the class Somethingdefinition

在定义的右;大括号 ( })之后需要一个分号 ( )class Something

回答by milo2016

you might have missed

你可能错过了

#ifdef  ROCKSTAR 

#endif <--- this might be missing