Jump to content
  • Advertisement
Sign in to follow this  
Corrosive

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.

If you intended to correct an error in the post then please contact us.

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)
	{
		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 :)

Share this post


Link to post
Share on other sites
Advertisement

_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;

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!