Jump to content
  • Advertisement
Sign in to follow this  
choffstein

Parse error issue

This topic is 4767 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

I am getting a parse error, but I can't figure out why. I have a static class defined as such: ConcreteFactory.h
/*
 *  ConcreteFactory.h
 *  Symphony Engine
 *
 *  Created by Corey Hoffstein on 8/31/05.
 *  Copyright 2005 Corey Hoffstein. All rights reserved.
 *
 */

#ifndef __CONCRETEFACTORY_H__
#define __CONCRETEFACTORY_H__

//#include "precompiled.h"

#include "Logger.h"
#include "AudioCore.h"
#include "InputManager.h"
#include "ResourceCore.h"
#include "ObjectFactory.h"

namespace Symphony
{
	class ConcreteFactory
	{
		private:
			static Logger *l;
			static AudioCore *ac;
			static InputManager *im;
			static ResourceCore *rc;
			static ObjectFactory *of;

		public:
			ConcreteFactory()
			{
			}
			~ConcreteFactory()
			{
			}
			
			static inline void createFactory()
			{
				l = new Logger();
				ac = new AudioCore();
				im = new InputManager();
				rc = new ResourceCore();
				of = new ObjectFactory();
			}
			
			static inline void destroyFactory()
			{
				//delete our audio core, input manager, and resource core
				if(ac) delete ac;
				if(im) delete im;
				if(rc) delete rc;
				
				//delete the object factory
				if(of) delete of;
				
				//close our logger
				if(l) delete l;
			}
			
			static inline Logger *getLogger()
			{
				return l;
			}
			static inline AudioCore *getAudioCore()
			{
				return ac;
			}
			static inline InputManager *getInputManager()
			{
				return im;
			}
			static inline ResourceCore *getResourceCore()
			{
				return rc;
			}
			static inline ObjectFactory *getObjectFactory()
			{
				return of;
			}
	};	
}
#endif

ConcreteFactory.cpp
/*
 *  ConcreteFactory.cpp
 *  Symphony Engine
 *
 *  Created by Corey Hoffstein on 8/31/05.
 *  Copyright 2005 Corey Hoffstein. All rights reserved.
 *
 */

#include "ConcreteFactory.h"

using namespace Symphony;

Logger *ConcreteFactory::l = NULL;
AudioCore *ConcreteFactory::ac = NULL;
InputManager *ConreteFactory::im = NULL;
ResourceCore *ConreteFactory::rc = NULL;
ObjectFactory *ConreteFactory::of = NULL;

Everything seems fine to me -- maybe not? Anyway, so I try to use it like this:
#include "ConcreteFactory.h"

...
ptr = ConcreteFactory::getObjectFactory()->createInstance(name, ptr);

And this is the error: error: parse error before `;' token Thoughts about this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You didn't say on which line (and in which file) the parse error occurred.
If it was on one of the lines:

Logger *ConcreteFactory::l = NULL;
AudioCore *ConcreteFactory::ac = NULL;
InputManager *ConreteFactory::im = NULL;
ResourceCore *ConreteFactory::rc = NULL;
ObjectFactory *ConreteFactory::of = NULL;

it may be because NULL is not defined. Replace all NULLs with 0 (zero). Alternatively you can include the header where NULL is defined (don't know which one), but using zero instead is recommended for C++ code (0 is a valid value for a pointer of any type).

If this didn't help you, please post the filename and line number where the error occurred.

Share this post


Link to post
Share on other sites
Whoops, sorry about that. On this line:

ptr = ConcreteFactory::getObjectFactory()->createInstance(name, ptr);

It was used before in a singleton instance, like this: ObjectFactory::getInstance()->, so I know that the issue is with the new ConcreteFactory.

Thanks.

Share this post


Link to post
Share on other sites
I assume the error occured on the line posted in the third sourcecode box. Did you bring the name ConcreteFactory into scope using a using declaration?

Enigma

Share this post


Link to post
Share on other sites
using namespace Symphony;
Logger *ConcreteFactory::l = NULL;
AudioCore *ConcreteFactory::ac = NULL;
InputManager *ConreteFactory::im = NULL;
ResourceCore *ConreteFactory::rc = NULL;
ObjectFactory *ConreteFactory::of = NULL;

Don't do this. Using directives merely import the requested symbols into the current scope. They don't actually place things in there. Try this instead:
namespace Symphony
{
Logger *ConcreteFactory::l = NULL;
AudioCore *ConcreteFactory::ac = NULL;
InputManager *ConreteFactory::im = NULL;
ResourceCore *ConreteFactory::rc = NULL;
ObjectFactory *ConreteFactory::of = NULL;
}

Share this post


Link to post
Share on other sites
The code it is within is within the Symphony namespace as well. What I mean by that is that code is from within a class, which is also within the Symphony namespace -- as such:


#include "ConcreteFactory.h"

namespace Symphony
{
class SomeClass
{
private:
....
public:
inline void someFunction()
{
...
ptr = ConcreteFactory::getObjectFactory()->createInstance(name, ptr);
}
};
}





Thanks for the thoughts so far.


EDIT: antareus -- unfortunately, no effect.

Share this post


Link to post
Share on other sites
I don't see any logic errors in what you've posted so far (barring the issue antareus pointed out - good spot). Can you try breaking the function down into:
ObjectFactory *of = ConcreteFactory::getObjectFactory();
ptr = of->createInstance(name, ptr);

to narrow down where the error is.

The only other thing I can think to suggest without seeing more code is to examine the preprocessor output to check that your inclusion guards haven't been accidentally duplicated in another file or tromped on by a compiler-defined symbol (since it's technically a name reserved for the implementation).

Enigma

Share this post


Link to post
Share on other sites
Error is in:
ObjectFactory *of = ConcreteFactory::getObjectFactory();
.
Ill see what I can do about preprocessor output (I'm new to xcode...)

Thanks.

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!