Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem with casts(i think)

Started by Corrosive Sep 23, 2004 at 4:20 PM 0 replies 650+ views
Original Post
Corrosive
Corrosive
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)
	{
		a_Dll = LoadLibrary("anaueld3d");
		if(!a_Dll)
		{
			MessageBox(NULL, "anaueld3d.dll falhou!", "Anauel - Erro", MB_OK | MB_ICONERROR);
			return E_FAIL;
		}
	}
	

	CREATERENDERDEVICE _CreateRenderDevice = 0;
	HRESULT hr;

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

	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 :)
To code is to make things come to life ;)
wild_pointer
wild_pointer
_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;
[size=2]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.