Jump to content

C++ unexpected end-of-file found

Guest
Go to solution Solved by Guest,

Something was wrong with the '}' character, I retyped it after deleting the entire line and it worked.

#include <gl/glew.h> #include <gl/freeglut.h>#include <iostream> using namespace std; void changeViewport(int w, int h) { 	glViewport(0, 0, w, h); } void render() { 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 	glutSwapBuffers(); } int main(int argc, char**argv) { 	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);	glutInitWindowSize(800, 600); 	glutCreateWindow("Title");	glutReshapeFunc(changeViewport); 	glutDisplayFunc(render);	GLenum err = glewInit(); 	if (GLEW_OK != err)	{ 		cerr << "GLEW Error" << endl;		return 1; 	} 		glutMainLoop(); 	return 0;}

I'm trying to figure out how to use opengl in visual studio 2010, it seems fine but I get the error

c:\users\noneofyourbusiness\main.cpp(37): fatal error C1004: unexpected end-of-file found

Usually to me this says there is a missing semi-colon or curly brace but I couldn't find anything. Anyone see the problem? I assume that "main.cpp(37)" means there's an error on line 37 but the only problem there I can see is that it doesn't exist. I guess there's something wrong with the return statement.

Link to comment
Share on other sites

Link to post
Share on other sites

Do you close the main function?

EDIT: Didn't see that bracket

Main Gaming Rig:

Spoiler

Core i7-4770, Cryorig M9i Cooler, ASUS B85M GAMER, 8GB HyperX Fury Red 2x4GB 1866MHz, KFA2 GTX 970 Infin8 Black Edition "4GB", 1TB Seagate SSHD, 256GB Crucial m4 SSD, 60GB Corsair SSD for Kerbal and game servers, Thermaltake Core V21 Case, EVGA SuperNOVA 650W G2.

Secondary PC:

Spoiler

i5-2500k OCed, Raijintek Themis, Intel Z77GA-70K, 8GB HyperX Genesis in grey, GTX 750 Ti, Gamemax Falcon case.

 

Link to comment
Share on other sites

Link to post
Share on other sites

open main.cpp, go to line 37, press backspace, press delete a few times and save. If there were any spaces or newlines at the end of the file that should remove them and save the file correctly.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

open main.cpp, go to line 37, press backspace, press delete a few times and save. If there were any spaces or newlines at the end of the file that should remove them and save the file correctly.

My file ends at line 36 though... there is nothing after the closing curly brace for the main function

 

Maybe a picture will help:

eQd8xxc.png?1

Link to comment
Share on other sites

Link to post
Share on other sites

My file ends at line 36 though... there is nothing after the closing curly brace for the main function

 

then insert a newline, save, retry.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

then insert a newline, save, retry.

Didn't work.

Link to comment
Share on other sites

Link to post
Share on other sites

Didn't work.

 

Since I'm not very experienced with visual studio I don't really know what else could be causing this, as a last effort you could try just making a new file and pasting your code over. Try making hello world to see if that gives you the same error.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Since I'm not very experienced with visual studio I don't really know what else could be causing this, as a last effort you could try just making a new file and pasting your code over. Try making hello world to see if that gives you the same error.

Yes, hello world gave me the same error.

EDIT: I made a new hello world project and there's a bunch of errors about not finding pdb files, which google said just to ignore, but there is no end of file error in the new project.

Link to comment
Share on other sites

Link to post
Share on other sites

Something was wrong with the '}' character, I retyped it after deleting the entire line and it worked.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×