Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error C1004: unexpected end-of-file found

Tags:

c++

visual-c++

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

    }
like image 420
mezamorphic Avatar asked Apr 02 '12 14:04

mezamorphic


4 Answers

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

class Something {

};  // <-- This semicolon character is missing in your code sample.
like image 99
Frédéric Hamidi Avatar answered Nov 06 '22 01:11

Frédéric Hamidi


Your class Something needs to have a terminating semicolon.

class Something{

}; // missing
like image 30
Konrad Avatar answered Nov 06 '22 00:11

Konrad


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

like image 20
Attila Avatar answered Nov 05 '22 23:11

Attila


you might have missed

#ifdef  ROCKSTAR 

#endif <--- this might be missing 
like image 2
milo2016 Avatar answered Nov 06 '22 00:11

milo2016