Programming with OpenGL #7

Posted by Mordi on May 31, 2012, 9:10 a.m.

Right now, my project is br0ke. It's giving me a bunch of errors, including an "unexpected end of file". I cannot see where the error lies.

Before this happened, I recorded a video to show my recent progress.

View video

This menu is set up like this.

// Main Menu
    menuSystem->AddButton("Play", centerX - 100, 300, 200, 35, MENU_MAIN, [=]()
        {
            GameEngine::ChangeState(new IntroState(), true);
        });
    menuSystem->AddButton("Settings", centerX - 100, 336, 200, 35, MENU_MAIN, [=]()
        {
            menuSystem->GoTo(MENU_SETTINGS);
        });
    menuSystem->AddButton("Quit", centerX - 100, 372, 200, 35, MENU_MAIN, [=]()
        {
            GameEngine::StopGame();
        });
 
    // Settings
    menuSystem->AddBox("Settings", centerX - 150, 250, 300, 250, MENU_SETTINGS);
    menuSystem->AddButton("Back", centerX - 75, 515, 150, 35, MENU_SETTINGS, [=]()
        {
            menuSystem->GoTo(MENU_MAIN);
        });

This means I can now have a simple menu with boxes and buttons. I'll need to add stuff.

Comments

DesertFox 12 years, 5 months ago

+1 for the music and the waving hamster. No clue on the EOF error though :<

blackhole 12 years, 5 months ago

An unexpected end of file means you forgot either a > or a } at the end of a function or template. It can sometimes also be caused by a missing semicolon on the end of a class if that class is the absolute last thing in the file. Theoretically a missing ) could also trigger it, but this is unusual. Since this usually causes a cascade of other errors, you should try to use those to pinpoint the issue.

Mordi 12 years, 5 months ago

I fixed my error. I think it was caused by the fact that I had two headers that were including each other. Do you know if this would lead to problems, blackhole? It was definitely a problem with how I was #including files anyway.

blackhole 12 years, 5 months ago

That should only cause a problem if you aren't using include guards. You are using include guards, right?

Mordi 12 years, 5 months ago

I use #pragma once in all my headers, but it is still possible for two headers to include each other, which creates an endless loop and thus an error, I believe.

sirxemic 12 years, 5 months ago

#pragma once should prevent that endless loop…

And if it doesn't,

#ifndef BLA
#define BLA

code

#endif

should fix it.