   Little help pls
  Hello,I''m getting a lot of errors in one of my header files when I try to compile it''s corresponding source file.Input.h   #ifndef Input_H_#define Input_H_typedef unsigned char UCHAR;#define SafeRelease(x)if (x) {x->Release(); x=NULL;}class cINPUT{public://The constructor will call several other functions to create the entire//input system. Destructor will call all the respective functions to //shutdown the entire input system.cINPUT();~cINPUT();//This is called in the constructor. This will create the keyboard device,//set the data format for the device, and set the behavior (cooperative// level), and acquire the device as well.BOOL CreateKeyboardDevice();//Process the input from the keyboard.void ProcessKeyboardInput();//This is called in the constructor. This will create the mouse device,//set the data format for the device, and set the behavior (cooperative// level), and acquire the device as well.BOOL CreateMouseDevice();private:HRESULThr; LPDIRECTINPUT8MainDIObject;LPDIRECTINPUTDEVICE8Keyboard;LPDIRECTINPUTDEVICE8Mouse;//Buffer to hold input from the keyboard.char buffer[ 256 ];};#endifI get 20 or so errors. Here are a few:c:\documents and settings\owner\desktop\anomaly engine\input.h(37) : error C2501: ''LPDIRECTINPUTDEVICE8'' : missing storage-class or type specifiersc:\documents and settings\owner\desktop\anomaly engine\input.h(38) : error C2146: syntax error : missing '';'' before identifier ''Mouse''c:\documents and settings\owner\desktop\anomaly engine\input.h(36) : error C2501: ''LPDIRECTINPUT8'' : missing storage-class or type specifiersAny help?!Here''s the source file.Input.cpp   #include "GlobalClass.h"cINPUT::cINPUT(){//Creates the main DirectInput8 object.hr = DirectInput8Create( Instance_Handle,  DIRECTINPUT_VERSION,  IID_IDirectInput8,  ( void** ) &MainDIObject,  NULL );CreateKeyboardDevice();}BOOL cINPUT::CreateKeyboardDevice(){hr = MainDIObject->CreateDevice( GUID_SysKeyboard, &Keyboard, NULL );hr = Keyboard->SetDataFormat( &c_dfDIKeyboard );hr = Keyboard->SetCooperativeLevel( WindowHandle, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE );if( Keyboard ) Keyboard->Acquire();return TRUE;}void cINPUT::ProcessKeyboardInput(){#define KEYDOWN( name, key ) ( name[key] & 0x80 )hr = Keyboard->GetDeviceState( sizeof( buffer ),( LPVOID ) &buffer );//Here is where we will make the appropriate actions in the game based//one what is inputed. This form should do:/*if( KEYDOWN( buffer, DIK_RIGHT ) ); Turn right. */}/*BOOL cINPUT::CreateMouseDevice(){hr = MainDIObject->CreateDevice( GUID_SysMouse, &Mouse, NULL );hr = Mouse->SetDataFormat( &c_dfDIMouse );hr = Mouse->SetCooperativeLevel( WindowHandle, DISCL_EXCLUSIVE | DISCL_FOREGROUND );And also, you may need this:   GlobalClass.cpp#ifndef GlobalHeader_H_#define GlobalHeader_H_#include <windows.h>#include <d3dx9.h>#include <dinput.h>#include "Input.h"#include "Application.h"#endif
  #include <dinput.h>In your Input.h file.Also, make sure the DirectX SDK include paths are at the top of the list of search paths in visual studio, otherwise it uses an old (DX7?) version which it has built in.   ---------------------------------------Let''s struggle for our dream of Game!http://andrewporritt.4t.com;  I also think that''s the problem, the compiler just doesn''t know what all that DX stuff is.Here''s what I''ve done (VC++ 6.0 of course):Tools->Options->Directories Tab->(Show directories for Include files)->C:\DXSDK\INCLUDETools->Options->Directories Tab->(Show directories for Library files)->C:\DXSDK\LIBIs this what I need in order to use ? Because it seems like it doesn''t know what the stuff is. Any help? This is really hindering my progress and killing morale But I shan''t stop. -Peter ;  Make sure that the DX include and lib directories are at the top of the list.  If they''re not, Visual Studio may try to use older versions.Another idea would be to copy the files you need from the C++\Common directory into your project directory.  That way, you can change parts of the common header files if the need arises during development.neneboricua ;  Thanks neneboricua19, I think that did it. Now I''m puzzled by another error. There are some errors in the DI initialization code.The code in this file is not able to access or see the private members of one of my other classes in another file. InstanceHandle in the constructor, and WindowHandle in the CreateKeyboardDevice() function are undeclared identifiers. The thing is, I have the cINPUT class declared as a friend of the MAIN_APPLICATION class which has those two variables. What''s up with that? I thought friends were supposed to be able to access the private members.Input.cpp #include "GlobalClass.h"cINPUT::cINPUT(){//Creates the main DirectInput8 object.hr = DirectInput8Create( InstanceHandle,  DIRECTINPUT_VERSION,  IID_IDirectInput8,  ( void** ) &MainDIObject,  NULL );CreateKeyboardDevice();}BOOL cINPUT::CreateKeyboardDevice(){hr = MainDIObject->CreateDevice( GUID_SysKeyboard, &Keyboard, NULL );hr = Keyboard->SetDataFormat( &c_dfDIKeyboard );hr = Keyboard->SetCooperativeLevel( WindowHandle, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE );if( Keyboard ) Keyboard->Acquire();return TRUE;}void cINPUT::ProcessKeyboardInput(){#define KEYDOWN( name, key ) ( name[key] & 0x80 )hr = Keyboard->GetDeviceState( sizeof( buffer ),( LPVOID ) &buffer );//Here is where we will make the appropriate actions in the game based//one what is inputed. This form should do:/*if( KEYDOWN( buffer, DIK_RIGHT ) ); Turn right. */}/*BOOL cINPUT::CreateMouseDevice(){hr = MainDIObject->CreateDevice( GUID_SysMouse, &Mouse, NULL );hr = Mouse->SetDataFormat( &c_dfDIMouse );hr = Mouse->SetCooperativeLevel( WindowHandle, DISCL_EXCLUSIVE | DISCL_FOREGROUND );Application.h #ifndef Application_H_#define Application_H_//////////////////////////////////////GLOBAL stuff for our application//////////////////////////////////////class cMAIN_APPLICATION{friend class cINPUT;public:cMAIN_APPLICATION();~cMAIN_APPLICATION();HWNDGet_Hwnd();HINSTANCEGet_Hinstance();BOOL InitWindowStructure();BOOL Run();BOOL KillWindow();//General functions that will be redefined in other classes.virtual FAR PASCAL MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc( hWnd, uMsg, wParam, lParam ); }virtual BOOL Init();virtual BOOL Shutdown();virtual BOOL Frame();BOOL MessagePump();protected:char ClassName[ 256 ];char CaptionName[ 256 ];//Properties of the main windowDWORDStyle;DWORDXPos;DWORDYPos;DWORDWidth;DWORDHeight;private:HWNDWindowHandle;HINSTANCEInstanceHandle;WNDCLASSEXWindowStructure;};//This is a pointer to our main application class.static cMAIN_APPLICATION*PtrMainApplication = NULL;static long FAR PASCAL AppWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );#endif;  Love them or hate them, friend functions/classes can cause all kinds of problems.  But I don''t think your particular situation merits the use of a friend relationship.A better idea might be to pass those two handles into your cINPUT object as arguments to its constructor.  You would then only have one constructor for cINPUT.  It would take two handles as arguments and store them internally for whenever it needs to use them.neneboricua ;  Good idea, but it''s not working Here''s what I did:I added cINPUT InputClass; into the private section of MAIN_APPLICATION, so it''s a class object inside another class. Now in the constructor for MAIN_APPLICATION after the window handle and instance handle have been created, I put this in:InputClass( InstanceHandle, WindowHandle ); to create the object with the specified arguements, and it''s giving me an error:c:\documents and settings\owner\desktop\anomaly engine\application.cpp(14) : error C2064: term does not evaluate to a functionMy constructor for the cINPUT object is simple and should be correct:cINPUT::cINPUT( HINSTANCE hinst, HWND hwnd ){//Set the handle to our instance and main windowhInst = hinst;hWnd  = hwnd; //Creates the main DirectInput8 object.hr = DirectInput8Create( hInst,  DIRECTINPUT_VERSION,  IID_IDirectInput8,  ( void** ) &MainDIObject,  NULL );CreateKeyboardDevice();};  Maybe I''ve missunderstood you but how are you actually declaring the object of type cINPUT?  You cannot call a constructor on an object that already exist (and has therefor already been constructed).Since there is no default constructor, you need to create the object dynamically at run-time.  You need to wait to construct/create the object until your window has been initialized.  The best way to do this is to create a pointer to an object of your input class in your main application.  Then, after your window has been created, actually construct the object:// Inside the class definition of cMAIN_APPLICATION put thiscINPUT* m_pInput;// Once your window has been created, do this...m_pInput = new cINPUT( InstanceHandle, WindowHandle );// When your app is about to exit, do this...SAFE_DELETE( m_pInput );  So you would access the functions of your input class through the "m_pInput" pointer like so...m_pInput->CreateKeyboardDevice();m_pInput->CreateMouseDevice();etc...neneboricua ;  I considered doing that, but I wasn''t sure if the object was already constructed. But thanks for the help, I got that fixed up. I appreciate your help neneboricua19.Not all control paths return a value in this function is the warning I''m getting. Where does this function not return a value? BOOL cMAIN_APPLICATION::Run(){MSG Msg;if( !RegisterClassEx( &WindowStructure ) ){return FALSE;}WindowHandle = CreateWindow( ClassName, CaptionName, Style, XPos, YPos, Width, Height, NULL, NULL, InstanceHandle, NULL );//Check to make sure the window was created successfullyif( !WindowHandle ){return FALSE;}//Show and update the windowShowWindow( WindowHandle, SW_NORMAL );UpdateWindow( WindowHandle );//Initialize COMCoInitialize( NULL );//If the window class structure and window itself were created//successfully, then enter the main loop and begin the message pump//Begin the message pump!ZeroMemory( &Msg, sizeof( MSG ) );//Main loopwhile( Msg.message != WM_QUIT ){//Handle any Windows messages if need beif( PeekMessage( &Msg, NULL, 0, 0, PM_REMOVE ) ) {TranslateMessage(&Msg);DispatchMessage(&Msg);} else {//Do the frame processing crap hereif( Frame() == FALSE ){break;}}}Shutdown();//Uninitialize COMCoUninitialize();//Unregister our window classUnregisterClass( ClassName, InstanceHandle );};quote:Original post by PoLiSh_Peta  I considered doing that, but I wasn''t sure if the object was already constructed. But thanks for the help, I got that fixed up. I appreciate your help neneboricua19.Not all control paths return a value in this function is the warning I''m getting. Where does this function not return a value?Right at the end after UnregisterClass( ClassName, InstanceHandle ); you should return a value.