Someone help me fix errors?

Started by
15 comments, last by Dave Hunt 18 years, 11 months ago
Hi I already opened a few threads askin for help with finding errors but nobody answered/could help me...not even tell me in which .cpp the error could be(which, i think, a few on this forum know). Would somebody look through my whole code? It's not very much...just a simple rendering loop that renders a colorful triangle in 3d space and Directinput(which is new and doesn't work). I also have the suspicion that my code is quite hard to read if i would do a development break and continue in a few months... Probably that someone i'm hoping to find could tell me how i could make my code better, because i'm not very good in c++(i just read a small book with ca 300 pages that told me everything about multithreading,interfaces,inheritance,templates but not what a simple forward decl is :/ ) I want to continue developing my engine but i'm stuck for 2months with that damn compilererrors in d3d9.h and nobody could help me. I don't even know in which .cpp file(s) the error could be :( I just don't know where to begin searching... Can please help me and look through my code? i would zip it and send it per email... regards, m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
Advertisement
-.. Òr you could copy-paste the errors here.

By the way, may I ask what IDE/compiler you're using?
i'll send you the link to my older thread...the compiler errors and some code are there... My older thread

regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
that's exactly hat i mean :/ none helps me no one answers(ok except pipo but he doesn't respond now too...) pls help me!

regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
If possible, send the project code to my mail and I'll check it out. Do not include binaries/build temporaries if you do so! (i.e. clean first)

ok i excluded now my new input part from the build and fixed all other errors...then i included ngInput in my build and now i only have 4 errors :/
but i dunno how i can fix them... it says error @ ngConfig.h: unexpected 'class' 'ngConfig'

ngConfig:
#ifndef NGCONFIG_H#define NGCONFIG_Hclass ngConfig {public:	ngConfig();	~ngConfig();	void Create(int XRes,int YRes,float FOV);	int   m_iXScreenRes;	int	  m_iYScreenRes;	float m_fFOV;	float m_fAspectRatio;};#endif


errors(all related to the one i mentioned i think):
Compiling...
ngInput.cpp
c:\programme\microsoft directx 9.0 sdk (april 2005)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
c:\Dokumente und Einstellungen\gregor\Eigene Dateien\nGin\ngConfig.h(6) : error C2236: unexpected 'class' 'ngConfig'
c:\Dokumente und Einstellungen\gregor\Eigene Dateien\nGin\ngConfig.h(6) : error C2143: syntax error : missing ';' before '{'
c:\Dokumente und Einstellungen\gregor\Eigene Dateien\nGin\ngConfig.h(6) : error C2447: '{' : missing function header (old-style formal list?)
c:\Dokumente und Einstellungen\gregor\Eigene Dateien\nGin\ngEngine.h(28) : error C2061: syntax error : identifier 'ngConfig'


THX coder for the offer...but if someone could finally help me fix this error everything will run fine (i hope)

regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
Quote:Original post by m4gnus
ok i excluded now my new input part from the build and fixed all other errors...then i included ngInput in my build and now i only have 4 errors :/
but i dunno how i can fix them... it says error @ ngConfig.h: unexpected 'class' 'ngConfig'


Since the class declaration itself is fine, the problem must be in whatever file includes ngConfig.h (i.e. ngInput.cpp). Post that file.
Kippesoep
You forgot a semi-colon (;) somewhere BEFORE you include 'ngconfig.h'.
ngInput.h includes ngEngine.h which includes ngConfig.h...
ngEngine.h:
#include <windows.h>//#include <d3dx9.h>//#include <d3d9.h>#include "ngConfig.h"#include "ngCamera.h"#ifndef NGENGINE_H#define NGENGINE_Hclass ngEngine {private:ngCamera  *m_pCamera;	float      m_fFOV,m_fAspectRatio,m_fNearClip,m_fFarClip;D3DXMATRIX m_matProj,m_matView,m_matWorld;D3DXVECTOR3 m_vPos,m_vLookAt,m_vUpVec;DWORD m_dwFVF;public:HWND	   g_hWindow;HINSTANCE g_hInst;//void SendMessage(ngMSG MSG,char *Params);void SetVF(DWORD FVF);void SetCamera(ngCamera *Camera);void render();ngEngine();   //Constructor~ngEngine();   //Destructorbool DoMsgLoop();void Init(ngConfig cfg);void Shutdown();};#endif

ngInput.h:
//file ngInput.h#include <DInput.h>#ifndef NGINPUT_H#define NGINPUT_H// #include "ngEngine.h" // auskommentiertclass ngEngine; // fwd-decl.class ngInput {  private:    ngEngine *m_pEngine;   public:	LPDIRECTINPUT8 m_pDIObj;    LPDIRECTINPUTDEVICE8  g_pSysKeyboard;    void Init(ngEngine *engine);    void GetKeyboardState();    ngInput();   ~ngInput();};class ngKeyboard {private:ngEngine *m_pEngine;LPDIRECTINPUT8 m_pDIObj;ngInput *m_pInput;public:LPDIRECTINPUTDEVICE8  g_pKeyboard;void CreateSysKeyboard(ngInput *input,ngEngine *engine);//void Create(LPDIRECTINPUTDEVICE8  pKeyboard,REFGUID rguid);bool GetKeyState(int Key);ngKeyboard();~ngKeyboard();}#endif


ngInput.cpp:
#include "ngInput.h"#include "ngEngine.h"#if DIRECTINPUT_VERSION < 0x0800  #if DIRECTINPUT_VERSION < 0x0700    #error "DIRECTINPUT_VERSION < 0x0700"  #else   #error "0x0699 < DIRECTINPUT_VERSION < 0x0800"  #endif#endifvoid ngInput::Init(ngEngine *engine) {m_pEngine=engine;DirectInput8Create(m_pEngine->g_hInst,0x0800,IID_IDirectInput8W,(void**)m_pDIObj,NULL);m_pDIObj->CreateDevice(GUID_SysKeyboard,&g_pSysKeyboard,NULL);g_pSysKeyboard->SetDataFormat(&c_dfDIKeyboard);g_pSysKeyboard->SetCooperativeLevel(m_pEngine->g_hWindow, 		DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); if (g_pSysKeyboard) g_pSysKeyboard->Acquire(); }void ngInput::GetKeyboardState() {#define KEYDOWN(name, key) (name[key] & 0x80) char     buffer[256]; HRESULT  hr; hr = g_pSysKeyboard->GetDeviceState(sizeof(buffer),(LPVOID)&buffer);//if(KEYDOWN(buffer,DIK_ESCAPE) m_pEngine.SendMessage(NGMSG_ESCAPE);	}ngInput::ngInput() {}ngInput::~ngInput() {}//***********************************// NGKEYBOARD//***********************************ngKeyboard::ngKeyboard() {}ngKeyboard::~ngKeyboard(){}bool ngKeyboard::GetKeyState(int Key) {#define KEYDOWN(name, key) (name[key] & 0x80) char     buffer[256];g_pKeyboard->GetDeviceState(sizeof(buffer),(LPVOID)&buffer);if(KEYDOWN(buffer,Key)) return true;}void ngKeyboard::CreateSysKeyboard(ngInput *input,ngEngine *engine) {m_pInput=input;m_pEngine=engine;m_pDIObj=m_pInput->m_pDIObj;m_pDIObj->CreateDevice(GUID_SysKeyboard,&g_pKeyboard,NULL);g_pKeyboard->SetDataFormat(&c_dfDIKeyboard);g_pKeyboard->SetCooperativeLevel(m_pEngine->g_hWindow, 		DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); if (g_pKeyboard) g_pKeyboard->Acquire(); }/*void ngKeyboard::Create(LPDIRECTINPUTDEVICE8  pKeyboard,REFGUID rguid,ngInput *input,ngEngine) {m_pInput=input;m_pDIObj=m_pInput.m_pDIObj;m_pDIObj->CreateDevice(GUID_SysKeyboard,&g_pKeyboard,NULL);g_pSysKeyboard->SetDataFormat(&c_dfDIKeyboard);g_pSysKeyboard->SetCooperativeLevel(m_pEngine->g_hWindow, 		DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); if (g_pSysKeyboard) g_pKeyboard->Acquire(); }}*/[/Source]


regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
It looks like you forgot a semicolon after the ngKeyboard class in the ngInput.h file.

This topic is closed to new replies.

Advertisement