Dziwne błędy w logu

0

Witam,
Jestem dopiero początkującym, ale już zdążyłem ogarnąć trochę na czym mw. polegają opisy błędów w logu przy kompilacji. Korzystam z Ms VC++ 2010 Express i przy kompilacji wywala mi błędy, które teoretycznie nie powinny się tam znaleźć np. brak średnika w(dobrze przejrzałem cały kod, a w szczególności okolice linijki, w której go powinno brakować, ale wszystko jest w porządku). Oto kod:

Main.cpp

#include <SFML/Graphics.hpp>

#include "Game1.h"
#include "Events.h"

sf::RenderWindow GameApp(sf::VideoMode(800,600,32), "SFML Game1");
Game1 Game;

int main()
{
	Game.onStart();

	while (GameApp.IsOpened())
	{
		GameEvent();
		Game.Update();
		Game.Draw();
	}
	return 0;
} 

Events.h

#ifndef Events_h
#define Events_h

#include <SFML/Graphics.hpp>
#include "Game1.h"

sf::Event Event;
extern sf::RenderWindow GameApp;
extern Game1 Game;

void GameEvent()
{
	while (GameApp.GetEvent(Event))
	{
		if (Event.Type == sf::Event::Closed)
			Game.Exit();
	}
}

#endif 

Game1.cpp

 #ifndef Game1_h
#define Game1_h

#include <SFML\Graphics.hpp>
#include "Events.h"

extern sf::RenderWindow GameApp;

class Game1
{
public:
	void onStart()
	{
		
	}

	void Update()
	{
		
	}

	void Draw()
	{
		GameApp.Clear();
		GameApp.Display();
	}
	
	void Exit()
	{
		GameApp.Close();
	}
};

#endif

Dodam, że korzystam z bibliotek SFML.

0

w którym dokładnie miejscu wywala błąd i podaj cały log kompilacji.

0

sorki, zapomniałem o logu :)

Oto on:

1>------ Build started: Project: SFML_Game1, Configuration: Debug Win32 ------
1>  main.cpp
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\events.h(9): error C2146: syntax error : missing ';' before identifier 'Game'
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\events.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\events.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\events.h(16): error C2228: left of '.Exit' must have class/struct/union
1>          type is 'int'
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(7): error C2146: syntax error : missing ';' before identifier 'Game'
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(7): error C2086: 'int Game' : redefinition
1>          e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\events.h(9) : see declaration of 'Game'
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(11): error C2228: left of '.onStart' must have class/struct/union
1>          type is 'int'
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(16): error C2228: left of '.Update' must have class/struct/union
1>          type is 'int'
1>e:\documents and settings\sysop\moje dokumenty\visual studio 2010\projects\sfml_game1\sfml_game1\main.cpp(17): error C2228: left of '.Draw' must have class/struct/union
1>          type is 'int'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
0

Klasyczne zapętlenie includów.
Events.h

#ifndef Events_h
#define Events_h
 
#include <SFML/Graphics.hpp>
// #include "Game1.h" // niepotrzebne tutaj, ale za to w Events.cpp musi być
 
sf::Event Event;
extern sf::RenderWindow GameApp;
class Game1;
extern Game1 Game;
 
void GameEvent(); // przenieś implementację do cpp
 
#endif

Powinno wystarczyć, ale mam wątpliwości, bo masz nieźle namieszane. Implementacje w nagłówkach umieszcza się jedynie na drodze świadomego wyjątku.
Polecam przeczytać to.

1 użytkowników online, w tym zalogowanych: 0, gości: 1