class dependencies and namespace

M

Mosfet

Hi,

I am trying to solve an issue with a dependency between two classes as
shown below :



atlwince.h (declaration and definition is done in the .h)
----------



struct _ATL_AYGSHELL_STATE
{
public:
// Handle initialization and cleanup of AYGSHELL
_ATL_AYGSHELL_STATE()
{
if (!AYGSHELL::SHSipInfo(...)) <- Not yet defined
{
m_nAygshellUIModel = Smartphone;
}
else
{
m_nAygshellUIModel = PocketPC;
}
}
};

const _ATL_AYGSHELL_STATE& ATL_CDECL _AtlGetAygshellState();
BOOL WINAPI AtlIsAygshellSupported();
int WINAPI AtlGetAygshellUIModel();
BOOL WINAPI AtlIsDRAEnabled();
void WINAPI AtlEnableDRA(BOOL bEnable);





namespace AYGSHELL
{
inline BOOL SHSipInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT
fWinIni)
{
const _ATL_AYGSHELL_STATE& aygshellState = _AtlGetAygshellState();
ASSERT(aygshellState.m_pfnSHSipInfo);

return aygshellState.m_pfnSHSipInfo(uiAction, uiParam, pvParam, fWinIni);
}


}// namespace AYGSHELL

As you can see I have a mutual dependency bewteen these two classes.
When I compile I get :

error C2653: 'AYGSHELL' : is not a class or namespace name
 
S

sonison.james

Hi,

I am trying to solve an issue with a dependency between two classes as
shown below :

atlwince.h (declaration and definition is done in the .h)
----------

struct _ATL_AYGSHELL_STATE
{
public:
// Handle initialization and cleanup of AYGSHELL
_ATL_AYGSHELL_STATE()
{
if (!AYGSHELL::SHSipInfo(...)) <- Not yet defined
{
m_nAygshellUIModel = Smartphone;
}
else
{
m_nAygshellUIModel = PocketPC;
}
}

};

const _ATL_AYGSHELL_STATE& ATL_CDECL _AtlGetAygshellState();
BOOL WINAPI AtlIsAygshellSupported();
int WINAPI AtlGetAygshellUIModel();
BOOL WINAPI AtlIsDRAEnabled();
void WINAPI AtlEnableDRA(BOOL bEnable);

namespace AYGSHELL
{
inline BOOL SHSipInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT
fWinIni)
{
const _ATL_AYGSHELL_STATE& aygshellState = _AtlGetAygshellState();
ASSERT(aygshellState.m_pfnSHSipInfo);

return aygshellState.m_pfnSHSipInfo(uiAction, uiParam, pvParam, fWinIni);
}

}// namespace AYGSHELL

As you can see I have a mutual dependency bewteen these two classes.
When I compile I get :

error C2653: 'AYGSHELL' : is not a class or namespace name


Just forward declare AYGSHELL::SHSipInfo before the declaration of
struct _ATL_AYGSHELL_STATE

namespace AYGSHELL
{
inline BOOL SHSipInfo(UINT uiAction, UINT uiParam, PVOID
pvParam, UINT fWinIni);
}

Thanks and regards
Sonison James
 
R

red floyd

Mosfet said:
Hi,

I am trying to solve an issue with a dependency between two classes as
shown below :



atlwince.h (declaration and definition is done in the .h)
----------



struct _ATL_AYGSHELL_STATE
{
public:
// Handle initialization and cleanup of AYGSHELL
_ATL_AYGSHELL_STATE()
{
if (!AYGSHELL::SHSipInfo(...)) <- Not yet defined
{
m_nAygshellUIModel = Smartphone;
}
else
{
m_nAygshellUIModel = PocketPC;
}
}
};

const _ATL_AYGSHELL_STATE& ATL_CDECL _AtlGetAygshellState();
BOOL WINAPI AtlIsAygshellSupported();
int WINAPI AtlGetAygshellUIModel();
BOOL WINAPI AtlIsDRAEnabled();
void WINAPI AtlEnableDRA(BOOL bEnable);





namespace AYGSHELL
{
inline BOOL SHSipInfo(UINT uiAction, UINT uiParam, PVOID pvParam,
UINT fWinIni)
{
const _ATL_AYGSHELL_STATE& aygshellState = _AtlGetAygshellState();
ASSERT(aygshellState.m_pfnSHSipInfo);

return aygshellState.m_pfnSHSipInfo(uiAction, uiParam, pvParam,
fWinIni);
}


}// namespace AYGSHELL

As you can see I have a mutual dependency bewteen these two classes.
When I compile I get :

error C2653: 'AYGSHELL' : is not a class or namespace name

Also, change your names. _ATL_AYGSHELL_STATE is a reserved identifier.
Identifiers with a leading underscore followed by an uppercase letter
are reserved to the implementation in all scopes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top