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

Author Topic: weird compiler problems  (Read 2297 times)

0 Members and 1 Guest are viewing this topic.

eniddelemaj

  • Newbie
  • *
  • Posts: 13
    • View Profile
weird compiler problems
« on: September 30, 2016, 04:24:59 pm »
hello people

first ,english is not my mother language so dont wonder.

the problem is:
i have two classes. the first is called 'base' for example and the second is called 'second'.
In the header file of base i create an object 'obj' of type second.
okay now when i want to start the programm , there is an error which says, that there is an
missing ';' befor 'obj'.
the first weird thing is:
...that there really is no missing semicolon.

the second weird thing is :
...that i can easily handle the problem by:
1. deleting the creation of an object of type second.
2.running the programm so there will be an error because the obj i use in other cpp files is missing.
3.writing the same thing again (create an object named 'obj' of type second)
4.it runs!?

okay now i can call that problem again by changing something in the cpp file of second.
now the error appears again.

i hope you understant my problem
thank you for reading an answear

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: weird compiler problems
« Reply #1 on: September 30, 2016, 04:46:23 pm »
1- This doesn't seem to be related to SFML in any way.  You might be better off on something like stackoverflow.
2- Without any code, it is hard to help, but this seems like includes are missing. Seems like you may be lacking some basic C++ knowledge? A good book could help you.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

eniddelemaj

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: weird compiler problems
« Reply #2 on: September 30, 2016, 05:03:44 pm »
im not a professional but i dont think that it is related on my experience.
i checked the includes ...everything is included.

yes but the problem is that it might be too much code but ill try.

this is the header file of class 'play' where i declared the movingBall object

//includes
 
#ifndef PLAY_HPP
#define PLAY_HPP
#include <SFML\Graphics.hpp>
#include "states.hpp"
#include "game.hpp"
#include "movingBall.hpp"
#include "wallCollision.hpp"

//there are other declarations but i dont show them to keep it clear to read

class play :public states
{
public:
       
        movingBall moBa; //the case when the compiler says that a semicolon is missing
                                     //i forgot to say that the compiler says that there is a missing type specifier
                                     //but nothing is marked red

        play();

        void draw(game &Game);
        void Update(game &Game);
        void handleEvents(game &Game);

protected:
 

header of the movingBall class:

//includes
#ifndef MOVINGBALL_HPP
#define MOVINGBALL_HPP
#include "play.hpp"
#include <time.h>



class movingBall
{
public:
        movingBall();
       

        //maybe it is connected with that much of arguments?! i dont think so..

        void ballIsMoving(sf::CircleShape &ball, sf::RectangleShape &barOne,
                              sf::RectangleShape &barTwo, sf::RectangleShape &wallOne,
                                          sf::RectangleShape &wallTwo,int &movementOne,int &movementTwo);


       

protected:
       

};

#endif

i forgot to say that the compiler says that there is a missing type specifier
but nothing is marked red!!



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: weird compiler problems
« Reply #3 on: September 30, 2016, 05:41:30 pm »
play.hpp includes movingBall.hpp, and movingBall.hpp includes play.hpp. This is a cyclic inclusion pattern that cannot compile.

Seems like it can easily be solved though, there's nothing that requires play.hpp in movingBall.hpp (unless you're not showing everything).
Laurent Gomila - SFML developer

eniddelemaj

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: weird compiler problems
« Reply #4 on: October 01, 2016, 01:37:28 pm »
it worked! im so dumb ...i already did have problems like this...thank you for your help !