This code from msdn won't work

I've got this in DemoApp.h:

1
2
3
4
5
6
7
8
9
10
11
12
template<class Interface>
inline void SafeRelease(
	Interface **ppInterfaceToRelease
	)
{
	if (*ppInterfaceToRelease != NULL)
	{
		(*ppInterfaceToRelease)->Release();

		(*ppinterfaceToRelease) = NULL;
	}
}



And I've got this in DemoApp.cpp:

1
2
3
4
5
6
7
DemoApp::~DemoApp()
{
	SafeRelease(&m_pDirect2dFactory);
	SafeRelease(&m_pRenderTarget);
	SafeRelease(&m_pLightSlateGrayBrush);
	SafeRelease(&m_pCornflowerBlueBrush);
}


I get these three errors:

>c:\users\mickaël\documents\visual studio 2010\projects\direct2d tutorial\direct2d tutorial\demoapp.h(41): error C2065: 'ppinterfaceToRelease' : undeclared identifier
1> c:\users\mickaël\documents\visual studio 2010\projects\direct2d tutorial\direct2d tutorial\demoapp.cpp(44) : see reference to function template instantiation 'void SafeRelease<ID2D1Factory>(Interface **)' being compiled
1> with
1> [
1> Interface=ID2D1Factory
1> ]
1>c:\users\mickaël\documents\visual studio 2010\projects\direct2d tutorial\direct2d tutorial\demoapp.h(41): error C2065: 'ppinterfaceToRelease' : undeclared identifier
1> c:\users\mickaël\documents\visual studio 2010\projects\direct2d tutorial\direct2d tutorial\demoapp.cpp(45) : see reference to function template instantiation 'void SafeRelease<ID2D1HwndRenderTarget>(Interface **)' being compiled
1> with
1> [
1> Interface=ID2D1HwndRenderTarget
1> ]
1>c:\users\mickaël\documents\visual studio 2010\projects\direct2d tutorial\direct2d tutorial\demoapp.h(41): error C2065: 'ppinterfaceToRelease' : undeclared identifier
1> c:\users\mickaël\documents\visual studio 2010\projects\direct2d tutorial\direct2d tutorial\demoapp.cpp(46) : see reference to function template instantiation 'void SafeRelease<ID2D1SolidColorBrush>(Interface **)' being compiled
1> with
1> [
1> Interface=ID2D1SolidColorBrush
1> ]
1>
1>Build FAILED.


What is the problem?


Edit: I also have these private variables in DemoApp.h:

1
2
3
4
5
6
private:
	HWND m_hwnd;
	ID2D1Factory* m_pDirect2dFactory;
	ID2D1HwndRenderTarget* m_pRenderTarget;
	ID2D1SolidColorBrush* m_pLightSlateGrayBrush;
	ID2D1SolidColorBrush* m_pCornflowerBlueBrush;
Last edited on
Ah man... I missed a capital "I"


1
2
3
4
5
6
7
8
9
10
11
12
template<class Interface>
inline void SafeRelease(
	Interface **ppInterfaceToRelease
	)
{
	if (*ppInterfaceToRelease != NULL)
	{
		(*ppInterfaceToRelease)->Release();

		(*ppinterfaceToRelease) = NULL; // *ppiiiiinterfaceToRelease
	}
}
Topic archived. No new replies allowed.