Jump to content
  • Advertisement
Sign in to follow this  
Crypter

Preprocessor madnes ...I think

This topic is 4116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, I cannot seem to find where the problem is at. The three files it is happening in are Video.h, Video.cpp, and Game.h. Game.h is the core game system class. Video.h/Video.cpp is an interface layer to control video configuation, and our engines Video SubSystem and drivers. It works fine if I #include Video.h one time (In either Video.cpp or Game.cpp), but if #include it in both I get synthax errors from the compilier:
Game.cpp
Video.cpp
Game.h(27) : error C2143: syntax error : missing ';' before '*'
Game.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Game.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
There are other files; however the above is the problem. Im having trouble finding WHERE and WHY though. At first I thought there was something with the #includes. That is, until I noticed this:

class Game {

	// Only one instance of the game //
	static Game*			m_pGame;

// We *Only* get those synthax errors if we declare the following varable
// (using SysVideo), which is declared in Video.h

	// Graphics SubSystem //
	//SysVideo*			m_pkVideo; // error??
	char*	m_pkVideo;                         // okay

// etc...
SysVideo is declared in Video.h:
#ifndef EVEH3D_VIDEO_H_INCLUDED_4532656FFCABD56DC87ABA_
# define EVEH3D_VIDEO_H_INCLUDED_4532656FFCABD56DC87ABA_

#include "Game.h"

class SysVideo {

	// Video driver. If none, engine will be set to HEL //
	Eveh3D::Video::VideoDriver*	m_pkVideo;

public:

	SysVideo ();
};


#endif //EVEH3D_VIDEO_H_INCLUDED_4532656FFCABD56DC87ABA_

Game.h:
#ifndef EVEH3D_GAME_H_INCLUDED_4532656FFCABD56DC87ABA_
# define EVEH3D_GAME_H_INCLUDED_4532656FFCABD56DC87ABA_

// EvolutionEngine Core library
#pragma comment (lib, "Eveh3D.lib")
#include <Core.h>

#include "Base.h"
#include "Settings.h"
#include "Video.h"

class Game {

	// Only one instance of the game //
	static Game*			m_pGame;

	// Graphics SubSystem //
	//SysVideo*				m_pkVideo;
	char*	m_pkVideo;

	// Game settings //
	SettingsManager*		m_pkSettings;

	// Prepare to start everything //
	virtual int Initialize (int argc, char** argv);

protected:

	Game ();

public:

	virtual ~Game ();

	// You got game! :)
	static Game* Get ();

	// Start game //
	virtual int Start (int argc, char** argv);

	// Get settings manager //
	inline virtual const SettingsManager* GetSettingsManager ();
};

#endif // EVEH3D_GAME_H_INCLUDED_4532656FFCABD56DC87ABA_

Does anyone see anything?? Any help would be appreciated. Thank you in advance.[smile]

Share this post


Link to post
Share on other sites
Advertisement
To add on my previus post,

An interesting thing is how the IDE says ::SysVideo exists,
but the compilier cannot find it within the global namespace.

Any suggestions?
Thanks[smile]

*edit: some day I will learn to spell[smile]
*edit2: ...and write[grin]

Share this post


Link to post
Share on other sites
Another interesting problem is that, if I compile with
the "Generate Preprocessor" option selected, Then it
compilies successfully (wtf?)

However, I do get the linker error:

LINK : fatal error LNK1181: cannot open input file '.\Debug\SettingsManager.obj'

I dont know if this is relivant or not, though.

I am using MSVC++ 2005.

Thanks again[smile]

Share this post


Link to post
Share on other sites

#ifndef EVEH3D_BASE_H_INCLUDED_4532656FFCABD56DC87ABA_
# define EVEH3D_BASE_H_INCLUDED_4532656FFCABD56DC87ABA_

/**
* Version information
* Update this information if a change has any global effect
*/


#define GAME_MAJOR 0
#define GAME_MINOR 1
#define GAME_REVISION 1
#define GAME_VERSIONSTRING "0.1.1"
#define GAME_TITLESTRING "Destinies -Of- Eveh"

#endif //EVEH3D_BASE_H_INCLUDED_4532656FFCABD56DC87ABA_



It basically contains global values and common constants.

Share this post


Link to post
Share on other sites
I got it working. Im still very confused at what is going on, though.

The only change I made was in SysVideo.h:

#ifndef EVEH3D_VIDEO_H_INCLUDED_4532656FFCABD56DC87ABA_
# define EVEH3D_VIDEO_H_INCLUDED_4532656FFCABD56DC87ABA_

// Include Core engine library here
#include <Core.h>

class SysVideo {

// Video driver. If none, engine will be set to HEL //
Eveh3D::Video::VideoDriver* m_pkVideo;

public:

SysVideo ();
};

// include game.h here
#include "Game.h"

#endif //EVEH3D_VIDEO_H_INCLUDED_4532656FFCABD56DC87ABA_



If Game.h is #included before SysVideo, it errors.
If it is #included after, it compilies.


I cannot have my code this way, as the video needs to access
the game class to access game configuations.

Any suggestions are welcome.

Share this post


Link to post
Share on other sites
Okay, I got it woking through foward declaring the class
in Game.h. I dont know of why that is neccessary though
...any ideas?

Or why it compilied (Although failed to link), when generating
preprocessor files ...Any ideas?

I'll give a cookie to anyone why can answer these questions[smile]

Everything is good though. Thanks again!

Share this post


Link to post
Share on other sites
Oh, I completely missed it!

You have a circular reference; game.h includes video.h, and video.h includes game.h.

I don't see any reason for the latter though, so the easy fix is to just take the include out of video.h altogether.

Although written for circular class references, this page will show you what is happening with the preprocessor when you have circular inclusions like that.

Share this post


Link to post
Share on other sites
Ah--That makes sense![smile]

I just cleaned up the code a bit, and everything is working now.

Thanks alot for the help-- lol, I never noticed that myself![smile]

Cookie for anyone else who answers the other question!

Share this post


Link to post
Share on other sites
place #pragma once in all your header files and that should solve the problem as it tells the compiler to only include the header file once nomatter how many files contain the #include *.h hope that helps

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!