Advertisement

COMPILER ERRORS

Started by February 15, 2000 08:08 PM
10 comments, last by PsYcHoPrOg 24 years, 7 months ago
I tried to compile my simple program (which is not finished) but I got annoying errors. I included DDraw.lib and did everything I was supposed to do. I am using VC++ Introductory edition. Here it is(long):

#define WIN32_LEAN_AND_MEAN
#define WINDOWNAME            "Window"
#define Height				  640
#define Width				  480

#include 
#include 
#include 
#include 
#include 
#include 

#include 

int GameInit();
int GameMain();
int GameEnd();

HWND			windowh   = NULL;
HINSTANCE		hinstance = NULL;

LPDIRECTDRAW4			lpdd	=NULL;
LPDIRECTDRAWSURFACE4	pbuff	=NULL;
LPDIRECTDRAWSURFACE4	bbuff   =NULL;
DDSCAPS					ddcap;
DDSURFACEDESC			ddsd;
DDBLTFX					bltfx;

LRESULT CALLBACK WindowProc(HWND hwnd,
							UINT msg,
							WPARAM	wparam,
							LPARAM  lparam)
{
	PAINTSTRUCT ps;
	HDC			hdc;

	switch(msg)
	{
	case WM_CREATE:
		{
			return(0);
		}break;
	case WM_PAINT:
		{
			hdc = BeginPaint(hwnd, &ps);
			EndPaint(hwnd, &ps);
			return(0);
		}break;
	case WM_DESTROY:
		
		{
			PostQuitMessage(0);
			return(0);
		}break;
	}
	default:break;
		return(DefWindowProc(hwnd, msg, wparam, lparam));
}

int WINAPI WinMain(HINSTANCE hinstance,
				   HINSTNACE hprevinstance,
				   LPSTR lpcmdline, 
				   int nShowCmd)
{
	HDC			hdc;
	HWND		hwnd;
	PAINTSTRUCT ps;
	MSG			msg;
	WNDCLASSEX  wc;

	wc.cbClsExtra				=0;
	wc.cbWndExtra				=0;
	wc.cbSize					=sizeof(WNDCLASSEX);
	wc.hbrBackground			=(HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.hCursor					=LoadCursor(NULL, IDC_ARROW);
	wc.hIcon					=LoadIcon(NULL, IDI_APPLICATION);
	wc.hIconSm					=LoadIcon(NULL, IDI_APPLICATION);
	wc.hInstance				=hinstance;
	wc.lpfnWndProc				=WindowProc;
	wc.lpszClassName			=WINDOWNAME;
	wc.lpszMenuName				=NULL;
	wc.style					=CS_DBLCLKS/CS_OWNDC/
								 CS_HREDRAW/CS_VREDRAW;

	if(!RegisterClassEx(&wc))
	{
		return(0);
	}

	if(!(hwnd = CreateWindowEx(NULL, WINDOWNAME, 
							   "BLT", WS_OVERLAPPEDWINDOW
							   /WS_VISIBLE, 0, 0, Width, Height, 
							   NULL, NULL, hinstance, NULL)))
	{
		return(0);
	}
	
	windowh = hwnd;
	instance = hinstance;
	
	GameInit();

	while(1)
	{
		if(msg.message == WM_QUIT);
		break;
		
		GameMain()
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return(msg.wParam);
	GameEnd();
}

int GameInit()
{
	if(FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
	{
		return(0);
	}
	
	if(lpdd->SetCooperativeLevel(windowh, DDSCL_ALLOWREBOOT/
								 DDSCL_EXCLUSIVE/
								 DDSCL_FULLSCREEN)!=DD_OK)
	{
		return(0);
	}

	if(lpdd->SetDisplayMode(640, 480, 16)!=DD_OK)
	{
		return(0);
	}
	
	memset(ddsd, 0, sizeof(ddsd));
	ddsd.dwSize  = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS / DDSD_FLIP;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE/

	if(FAILED(lpdd->CreateSurface(&ddsd, &pbuf, NULL)))
	{
		return(0);
	}
}
The errors are: error C2146: syntax error : missing '';'' before identifier ''pbuff''(If I get rid of the next error this one will clear) error C2501: ''LPDIRECTDRAWSURFACE4'' : missing storage-class or type specifiers(I DID INCLUDE STORAGE CLASS AND TYPE SPECIFIERS!) fatal error C1004: unexpected end of file found(I know the answer to this one) If anyone can help... PLEASE DO!!! Games are the path to another dimension.
D:
O.k. I didn't look at the program thoroughly but:

(1) syntax error missing ';' before identifier etc..
I'd say that one comes up because of the next error (see 2)

(2) LPDIRECTDRAWSURFACE4 missing storage-class or type-specifier
I am just guessing but you need to check:
(a) your include files at the start of the program to make sure ddraw.h is there

(b) that both ddraw.lib and dxguid.lib (I think they are the correct names - I don't use direct draw regularly) are added in the linkage section of your compiler. I think that is under Tools - Options - Links in VC++6.

(c) the file locations (include and library) making sure the paths go to the correct places and the correct ddraw.h is at the include location.

(3) Unexpected end of file
Either error number 2 is causing this, or you have a missing semi-colon / bracket somewhere.

It looks like you are missing a return command at the end of your main program (see WINAPI) too.

Paulcoz.

Edited by - paulcoz on 2/16/00 5:41:33 PM
Advertisement
Hi.

I don't know if this will help your DirectX problems but I did notice a couple of other errors that may be a problem. I don't know if you've already fixed these but here we go:


  • In WindowProc the default is outside the switch.
  • In WindowProc all your breaks are unreachable since you return out before you get to them.
  • In WinMain it should be HINSTANCE
  • After you create the window instance is not defined anywhere.
  • ; after GameMain()
  • When you memset in GameInit() you need &ddsd as the first param.
  • ; after ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE
  • When you try to create the surface I think you mean &puff


I hope I don't appear to be picky but I find that sometimes wierd bugs can pop out of a missing ; or misplaced }.


--------------
Andrew

Edited by - acraig on 2/15/00 9:51:51 PM

Edited by - acraig on 2/15/00 9:53:24 PM
I have fixed all of the bugs that you two have pointed out, but I still get the same errors. If anyone could please help me out, it would be great!
D:
hmm....make sure u r including the latest directx .h files...don''t forget to check the directory sequence in the options. other solution is to replace the .h files in the \INCLUDE folder with the latest dx .h files.
(i heard that msvc came with dx3)

Another thing is, try #define STRICT before including anything. It solved a lot of problem for me... and maybe u too!
"after many years of singularity, i'm still searching on the event horizon"
Another thought is that you #define Height and Width before you include your header files. If any of the headers decide to use either Height or Width as a variable name, strange errors might result.
Advertisement
I don''t think you can create a directdraw4 just by calling the DirectDrawCreate. When I create a directdraw 7 object i create a directdraw1 first and call queryinterface with it.
Could that be you''re problem?
Hello,

I see two problems.

1. You have 7 undefined #include(s)

2. You do not show including ddraw.h ( #include )

PigHeaded
quote: Original post by PigHeaded
I see two problems.
1. You have 7 undefined #include(s)


This is because the board uses HTML tags, so all of the headers are taken to be tags. I think there is a way to make them come out properly but it's a pain if you just want to cut and paste code. You can use View->Source as a last resort.


Andrew

Edited by - acraig on 2/16/00 10:47:15 AM
PLEASE HELP!!!!!!
D:

This topic is closed to new replies.

Advertisement