Jump to content
  • Advertisement
Sign in to follow this  
lougv22

error C2027: use of undefined type 'Star::DialogAction'

This topic is 3301 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 get the following error: "error C2027: use of undefined type 'Star::DialogAction'" in the file below:
Convert.h


#ifndef _STAR_CONVERT_H_
#define _STAR_CONVERT_H_
#pragma once

#include "PathwaysShared.h"
#include <Engine/Vector3f.h>
#include <Engine/Quaternion.h>
#include <Engine/Any.h>
#include <Exil/ExilElement.h>
#include "AvatarDefinition.h"
#include "DialogAction.h"

namespace Star
{
	namespace Convert
	{
            ........
            DialogAction::DialogActionType mapStringToActionType(const String& actionString);
             
        };
};

#endif
The enumeration DialogActionType is declared like so:
DialogAction.h

#ifndef _STAR_DIALOGACTION_H_
#define _STAR_DIALOGACTION_H_

#include "PathwaysShared.h"

namespace Star
{

	class PATHWAYSSHARED_API DialogAction
	{
	public:
	
		enum DialogActionType
		{
			DIALOG_ACTION_NONE = 0,
			DIALOG_ACTION_EXIT = 1,
			DIALOG_ACTION_GOTO = 2,
			DIALOG_ACTION_RUN = 3,
			DIALOG_ACTION_SET = 4
		};

	public:
		DialogAction();

		~DialogAction();

        };
};

#endif
So why am I getting this error? The enumeration is declared properly and I have included the file it is declared in (DialogAction.h) in Convert.h.

Share this post


Link to post
Share on other sites
Advertisement
It sounds like a circular definition problem. In order to access a nested type of a class a full definition for that class needs to be available, not just a forward declaration. If your DialogActions.h header ever includes, directly or indirectly, a header that in turn includes DialogActions.h, then this kind of problem can show up.

Share this post


Link to post
Share on other sites
Yes, there was a circular dependency. Class Convert included class PathwaysShared:


Convert.h

#ifndef _STAR_CONVERT_H_
#define _STAR_CONVERT_H_
#pragma once

#include "PathwaysShared.h"



And class PathwaysShared includes class PathwaysSharedForwards AND class Convert:


PathwaysShared .h

#ifndef _PATHWAYSSHARED_H_
#define _PATHWAYSSHARED_H_
#pragma once

#include "PathwaysSharedForwards.h"

#include "Convert.h"



And then PathwaysSharedForwards includes DialogAction, but not an actual include but a forward declaration:


PathwaysSharedForwards .h

#ifndef _STAR_PATHWAYSSHAREDFORWARDS_H_
#define _STAR_PATHWAYSSHAREDFORWARDS_H_
#pragma once

#include "PathwaysShared.h"


namespace Star
{
class DialogAction;
..................
..................


Sooo, I took out the forward declaration to DialogAction from PathwaysSharedForwards, so now Convert like this:


Convert.h

#ifndef _STAR_CONVERT_H_
#define _STAR_CONVERT_H_
#pragma once

#include "PathwaysShared.h"
#include <Engine/Vector3f.h>
#include <Engine/Quaternion.h>
#include <Engine/Any.h>
#include <Exil/ExilElement.h>
#include "AvatarDefinition.h"
#include "DialogAction.h"

namespace Star
{
namespace Convert
{
DialogAction::DialogActionPtr mapStringToActionType(const String& actionString);
};
};

But now I get a different error in the line above:

"error C2653: 'DialogAction' : is not a class or namespace name"

Share this post


Link to post
Share on other sites
You're voodoo programming. Adding or removing lines without understanding why you're adding or removing a line is a bad thing. Your convert header needs the complete definition found in the dialog header. Think about why a circular inclusion would cause it not to find the complete definition and then break the cycle.

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!