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

fatal error C1004: unexpected end-of-file found

本文关键字:文件 结尾 意外 发现 C1004 致命错误      更新时间:2023-10-16

我收到了上面的错误消息(我在谷歌上搜索了一下,发现这与缺少大括号或其他什么有关),但是,我看不到这个缺少的括号在哪里?

#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) {}
        };
    }

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

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

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

class Something{
}; // missing

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

您可能错过了

#ifdef  ROCKSTAR 
#endif <--- this might be missing