intrigued_66
intrigued_66

Reputation: 17220

fatal error C1004: unexpected end-of-file found

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

    }

Upvotes: 9

Views: 41878

Answers (5)

MHX
MHX

Reputation: 43

As per CodeProject: In my case, I fixed the error since there was a missing new line on my resource.rc file. (Basically, you just hit enter at the end of the file)

Upvotes: 0

milo2016
milo2016

Reputation: 31

you might have missed

#ifdef  ROCKSTAR 

#endif <--- this might be missing 

Upvotes: 3

Konrad
Konrad

Reputation: 40947

Your class Something needs to have a terminating semicolon.

class Something{

}; // missing

Upvotes: 6

Attila
Attila

Reputation: 28762

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

Upvotes: 3

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 262919

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

class Something {

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

Upvotes: 23

Related Questions