Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: missing ';' before identifier...... It really doesn't seem to be missing one?  (Read 4974 times)

0 Members and 1 Guest are viewing this topic.

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
I have a bit of an issue. I'm trying to make my objects and everything, but I always run into this error. No, not always. Just with these two files, MainMenu.cpp/hpp and SplashScreen.cpp/hpp.

I'll try the following code like:
MainMenu mainMenu;
 

Imediatly it says ther there is a missing ";" before the identifier mainMenu, when I hover over it, Visual Studio pop's up with "Error, Expected a ";""

I've looked at my files, and they look just fine, I'll show  MainMenu.cpp and .hpp

MainMenu.cpp
#include "stdafx.h"
#include "MainMenu.h"
void MainMenu::GetResult(sf::RenderWindow& renderWindow)
{
        //Not yet finished...... obviously.
}
 

MainMenu.h
#ifndef MAINMENU_H
#define MAINMENU_H
class MainMenu{
public:
        void GetResult(sf::RenderWindow& renderWindow);
        enum MainMenuResult{Play,Quit,Load};
};
#endif
 

Now I know how this error can kinda roll down from any linked file, so I'll also show stdafx

stdafx.h
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#ifndef STDAFX_H
#define STDAFX_H

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>
#include <iostream>



// TODO: reference additional headers your program requires here
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

#endif
 

As I said, I can't find were its saying I'm missing an ";". To me the whole error really makes no sense. I mean, it works with BetweenScreens, and thats just a bunch of random public methods for loading screens. So, yea, I look foreward to hearing if anyone else ever had this issue.

Yes, I used google, but the problem seems to have a unlimited ammounts of fixes/causes so it wasn't much help.

Anyways, let me know what you think, and have a wonderful day! :D

EDIT, oh almost forgot the original position of the erroring code in the main file:

void Genesis::loadMainMenu(sf::RenderWindow& renderWindow)
{
        BetweenScreens betweenScreens; //Works Fine
        betweenScreens.LoadingMenuScreen(renderWindow);
        MainMenu mainMenu; //Error   ...and will still error if I got rid of the above code.

}
 
« Last Edit: July 17, 2012, 05:53:00 pm by Flash619 »

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
The error is a strange way to say: "MainMenu is undefined here".
Are u including MainMenu.h in the file where you are getting this error?
TGUI: C++ SFML GUI

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
The error is a strange way to say: "MainMenu is undefined here".
Are u including MainMenu.h in the file where you are getting this error?

Yep.
#include "MainMenu.h"
 
:) Any other things that could cause it?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Is the provided code really the full code (e.g. Genesis class)?

You should remove everything step by step at the position where it doesn't produce an error any more start searching.

Also the use of stdafx.h isn't really needed... ;-)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Is the provided code really the full code (e.g. Genesis class)?

You should remove everything step by step at the position where it doesn't produce an error any more start searching.

Also the use of stdafx.h isn't really needed... ;-)

You say its not needed, but let me tell you, Visual Basic will let me know if its not there. -_-

I figure it has nothing to do with genesis.cpp since every other time I used similar code in the file, it never error'd except for once. Which once again, made no sense considering I could put code right above it that did the same thing for a seperate file, and it would work prefectly as I showed above.

I mean, everhting is there, its including the header, everything that needs a ";" has one, the classes are all setup, the file has no visable errors, or any compile errors, except for this one error that I have never, been able to get rid of.

EDIt

Also, I deleted everything else in the file to only this:
Genesis.cpp
#include "stdafx.h"
#include "Genesis.h"
#include "MainMenu.h"
#include "BetweenScreens.h"
#include "SplashScreen.h"
#include "WindowEngine.h"
void Genesis::loadMainMenu(sf::RenderWindow& renderWindow)
{
        BetweenScreens betweenScreens; //<------Still works fine
        betweenScreens.LoadingMenuScreen(renderWindow);
        MainMenu mainMenu;                  //<--------Still has an error.

}
 
« Last Edit: July 17, 2012, 05:46:58 pm by Flash619 »

DJuego

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
"MainMenu.h" or "MainMenu.hpp"?  ::)

DJ

I supposse it is a typo in post:

 

MainMenu.hpp
#ifndef MAINMENU_H
#define MAINMENU_H
class MainMenu{
public:
        void GetResult(sf::RenderWindow& renderWindow);
        enum MainMenuResult{Play,Quit,Load};
};
#endif
 

« Last Edit: July 17, 2012, 05:52:16 pm by DJuego »

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
"MainMenu.h" or "MainMenu.hpp"?  ::)

DJ

The file extension for the header files for visual studio is by default ".h"

I fixed it to avoid further confusion. :)

ALSO, I have been trying to find the source of this error for several days. I can completely blank MainMenhu.h of everything except the class itself, same error, blank out MainMenu.cpp, same error, Delete everything in Genesis.cpp besides the method calling MainMenu, same error.
« Last Edit: July 17, 2012, 05:58:51 pm by Flash619 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
You say its not needed, but let me tell you, Visual Basic will let me know if its not there. -_-
Visual Basic? ??? ;D
That's because you didn't create an empty project, as you should have. ;-)
You can also disable it in the project settings.

Anyway, hace you tried to comment out the enum decleration?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
You say its not needed, but let me tell you, Visual Basic will let me know if its not there. -_-
Visual Basic? ??? ;D
That's because you didn't create an empty project, as you should have. ;-)
You can also disable it in the project settings.

Anyway, hace you tried to comment out the enum decleration?

I meant Visual Studio. Haha, oh visual basic... good times.

I just did, still has the same error. :|

OH WOW, found the error. In my Enum for Genesis's state, I used "MainMenu" in it, so it keeps expecting that when I say "MainMenu" I'm refering to the Enum, and not the class. I'll change the enum to "showingMainMenu" to resolve this. Thanks a bunch!
« Last Edit: July 17, 2012, 06:02:03 pm by Flash619 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
It has nothing to do with the Genesis class... ::) :P
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Flash619

  • Full Member
  • ***
  • Posts: 142
    • View Profile
It has nothing to do with the Genesis class... ::) :P

xD I figured it was in Genesis considering that two seperate classes had the same issue, and the only similarity was where they were called. I never checked the enum though.  ::)

 

anything