Skip to main content
gamedev.net
🔒 Locked

Error After adding DirectInput Code

Started by LittleFreak 6 replies 950+ views
Original Post
LittleFreak
LittleFreak
Ok I added the input code to my new engine I am working on and when I went to go compile the .dll I got an error but not in my code but microsofts code... c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iostream(9) : error C2143: syntax error : missing ';' before 'namespace' why am I getting this error in iostream? Anyone else have this issue?
jflanglois
jflanglois
It's not necessarily a bug in Microsoft's code, you know.
Can we see your code around where you include iostream?
LittleFreak
LittleFreak
Declarations:
LPDIRECTINPUT8  pDXInput;LPDIRECTINPUTDEVICE8  pDXKeyboard; #define    KeyDown(data, n)    ((data[n] & 0x80) ? true : false)#define    KeyUp(data, n)    ((data[n] & 0x80) ? false : true)class KAIGANGRAPHICS_API K3DInput{public:	K3DInput(HWND wndHandle  = NULL);	~K3DInput();	int KeyboardState();private:	unsigned char keystate[256];}[/Source]

Definations:
K3DInput::K3DInput(HWND wndHandle){	HRESULT hr;	hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&pDXInput, NULL);	if(FAILED(hr))		return; //Error	hr = pDXInput->CreateDevice(GUID_SysKeyboard, &pDXKeyboard, NULL);	if(FAILED(hr))		return; //Error	hr = pDXKeyboard->SetDataFormat(&c_dfDIKeyboard); 	if(FAILED(hr))		return; //Error	hr = pDXKeyboard->SetCooperativeLevel(wndHandle, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); 	if(FAILED(hr))		return; //Error	hr = pDXKeyboard->Acquire();	if(FAILED(hr))		return; //Error}K3DInput::~K3DInput(){		if (pDXKeyboard)		pDXKeyboard->Release();  	if (pDXInput)		 pDXInput->Release();}int K3DInput::KeyboardState(){		HRESULT hr;    	hr = pDXKeyboard->GetDeviceState(sizeof(unsigned char[256]), (LPVOID)keystate);	if(FAILED(hr))		return -1; //Error	int KeyPressed;	if(KeyDown(keystate, DIK_NUMPAD1))		KeyPressed = 1;	if(KeyDown(keystate, DIK_NUMPAD2))		KeyPressed = 2;	if(KeyDown(keystate, DIK_NUMPAD3))		KeyPressed = 3;	if(KeyDown(keystate, DIK_NUMPAD4))		KeyPressed = 4;	if(KeyDown(keystate, DIK_NUMPAD5))		KeyPressed = 5;	if(KeyDown(keystate, DIK_NUMPAD6))		KeyPressed = 6;	if(KeyDown(keystate, DIK_NUMPAD7))		KeyPressed = 7;	if(KeyDown(keystate, DIK_NUMPAD8))		KeyPressed = 8;	if(KeyDown(keystate, DIK_NUMPAD9))		KeyPressed = 9;	return KeyPressed;}
jflanglois
jflanglois
Make sure you have a semicolon following the closing brace of the definition of the K3DInput class.
LittleFreak
LittleFreak
Wow its amazing what you forget to do lol...
LittleFreak
LittleFreak
Ok same code as before but now Im getting a differnt error after fixing the last one...

Linking...
Creating library Debug/KaiganGraphics.lib and object Debug/KaiganGraphics.exp
KaiganGraphics.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboard
KaiganGraphics.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
KaiganGraphics.obj : error LNK2019: unresolved external symbol _DirectInput8Create@20 referenced in function "public: __thiscall K3DInput::K3DInput(struct HWND__ *)" (??0K3DInput@@QAE@PAUHWND__@@@Z)
KaiganGraphics.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A
Debug/KaiganGraphics.dll : fatal error LNK1120: 4 unresolved externals

Any Ideas?
Armadon
Armadon
It seems that you haven't linked the appropriate libraries.
Add dinput8.lib and dxguid.lib to your linker input settings
Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies.

I hope this helps.
Take care.
LittleFreak
LittleFreak
Yep thanks.... I forgot to do that when I changed my solution around

Topic Locked

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

Sign in to reply to this topic.