# Problem with casts(i think)

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

## Recommended Posts

Hi there... Im trying to make some dll modules and work with abstract functions(interfaces). Its my first attempt so, maybe the question will be a little dumb, but im not used to OOP as i should be! Well, enough chit chat, the problem is that im receiving an "C2275" error message like that: c:\projetos\p1\anauelrender.h(41) : error C2275: 'CREATERENDERDEVICE' : illegal use of this type as an expression c:\projetos\p1\anauel.h(43) : see declaration of 'CREATERENDERDEVICE' And i think the problem is in the declaration, see below:
extern "C"
{
HRESULT CreateRenderDevice(HINSTANCE hDll, AnauEngine **pInterface);
typedef HRESULT (*CREATERENDERDEVICE) (HINSTANCE hDll, AnauEngine **pInterface);
HRESULT ReleaseRenderDevice(AnauEngine **pInterface);
typedef HRESULT (*RELEASERENDERDEVICE) (AnauEngine **pInterface);

}


and then defined as below:
HRESULT AnauelRenderer::CreateDevice(char *chAPI)
{
char buffer[300];

if(strcmp(chAPI, "d3d") ==0)
{
if(!a_Dll)
{
MessageBox(NULL, "anaueld3d.dll falhou!", "Anauel - Erro", MB_OK | MB_ICONERROR);
return E_FAIL;
}
}

CREATERENDERDEVICE _CreateRenderDevice = 0;
HRESULT hr;

if(!_CreateRenderDevice) return E_FAIL;

hr = _CreateRenderDevice(a_Dll, &a_Device);
if (FAILED(hr))
{
MessageBox(NULL, "CreateRenderDevice da dll falhou!", "Anauel - Erro", MB_OK | MB_ICONERROR);
a_Device = NULL;
return E_FAIL;
}
return S_OK;
}


I wanna know if there is something wrong about VC++ 6.0 with this type of casting, and what should i do to avoid that error? one more thing... i also used that: typedef struct AnauelRenderer *ANAUELRENDERER; and AnauelRenderer is a class, making the compiler generate this error also:
c:\projetos\p1\anauelrender.h(20) : warning C4099: 'AnauelRenderer' : type name first seen using 'class' now seen using 'struct'
c:\projetos\p1\anauelrender.h(4) : see declaration of 'AnauelRenderer'


I just placed all of this because i think its all corelacioned. I hope you guys understand the mess i placed behind :)

##### Share on other sites
_CreateRenderDevice (CREATERENDERDEVICE) GetProcAddress(a_Dll, "CreateRenderDevice");

Should probably be:

_CreateRenderDevice = (CREATERENDERDEVICE)GetProcAddress(a_Dll, "CreateRenderDevice");

And I don't see why you wouldn't expect that second error if AnuaelRender is already declared as a class. Perhaps you mean:

typedef AnauelRenderer* ANAUELRENDERER;

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 17
• 13
• 14