Sign in to follow this  
ctaclas

syntax error trying to create d3d interface

Recommended Posts

hi, i'm trying to make my own class to do everything d3d related... i'm off to a bad start though, i'm trying to set up an LPDIRECT3D9 and it tells me its missing a semicolon. i'm pretty sure it's something else, i don't think it's missing a semicolon. i just can't see the error... i included relevent code and the compiler output thanks header file
#ifndef D3DOBJ_H
#define D3DOBJ_H

#include <d3d9.h>

class Cd3dobj
{
public:
	Cd3dobj(void);
	~Cd3dobj(void);
	bool init(HWND hwnd);
private:
	LPDIRECT3D9			pD3D;
	LPDIRECT3DDevice9	pd3dDevice;
};

#endif

cpp file
#include "d3dobj.h"

Cd3dobj::Cd3dobj(void)
{
	pD3D = NULL;
	p3dDevice = NULL;
}

Cd3dobj::init(HWND hwnd)
{
	if( ( pD3D = Direct3DCreate9(D3DSDK_VERSION) ) == NULL )
		return false;
	else return true;
}

Cd3dobj::~Cd3dobj(void)
{
}


Compiling... d3dobj.cpp c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.h(14) : error C2146: syntax error : missing ';' before identifier 'pd3dDevice' c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.h(14) : error C2501: 'Cd3dobj::LPDIRECT3DDevice9' : missing storage-class or type specifiers c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.h(14) : error C2501: 'Cd3dobj::pd3dDevice' : missing storage-class or type specifiers c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.cpp(6) : error C2065: 'p3dDevice' : undeclared identifier c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.cpp(10) : error C2556: 'int Cd3dobj::init(HWND)' : overloaded function differs only by return type from 'bool Cd3dobj::init(HWND)' c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.h(11) : see declaration of 'Cd3dobj::init' c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.cpp(10) : error C2371: 'Cd3dobj::init' : redefinition; different basic types c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.h(11) : see declaration of 'Cd3dobj::init' c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\d3dobj.cpp(11) : error C2065: 'D3DSDK_VERSION' : undeclared identifier Build log was saved at "file://c:\Documents and Settings\Chris\My Documents\Visual Studio Projects\Direct3d\Debug\BuildLog.htm" Direct3d - 7 error(s), 0 warning(s) ---------------------- Done ---------------------- Build: 0 succeeded, 1 failed, 0 skipped

Share this post


Link to post
Share on other sites
The problem with the missing semicolon is that there is an identifier that the compiler doesn't know (LPDIRECT3DDevice9 in that case). Try using LPDIRECT3DDEVICE9 instead.

Share this post


Link to post
Share on other sites
thanks, hehe i just needed another set of eyes to catch that :)

originally i had it as LPDirect3DDevice, then i fixed it to LPDIRECT3DDevice

once i fixed it completely i was able to chase down the other bugs in it so it compiles now

thanks a lot :)

Share this post


Link to post
Share on other sites
Same error I get, but I'm using the correct names for my variable types. Check out my thread, I need some help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this