Archived

This topic is now archived and is closed to further replies.

Metal Typhoon

unexpected end of file found???

Recommended Posts

quote:
Original post by tangentz
Absolutely no friggin' idea what you're talking about.



Kami no Itte ga ore ni zettai naru!


neither do i.. take a looka t this simple example ...

#include <windows.h>

BOOL Keys[256];
BOOL Done = false;

LRESULT CALLBACK WndProc (HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{

switch (msg)
{
case WM_KEYDOWN:
Keys[wparam] = true;
break;

case WM_KEYUP:
Keys[wparam] = false;
break;

}

return DefWindowProc (hwnd,msg,wparam,lparam);
}

int WINAPI WinMain (HINSTANCE hinstance,HINSTANCE hprevInstance,LPSTR CmdLine,int ShowCmd)
{
WNDCLASS wc;
MSG msg;
HWND hwnd;

wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = NULL;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hIcon = LoadIcon (NULL,IDI_APPLICATION);
wc.hInstance = hinstance;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "X";
wc.lpszMenuName = NULL;
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;

if (!RegisterClass (&wc))
{
MessageBox (NULL,"RegisterClass","Error # 1",MB_OK|MB_ICONEXCLAMATION);
return 0;
}

hwnd = CreateWindow ("X","X",WS_OVERLAPPEDWINDOW,50,50,800,600,NULL,NULL,hinstance,NULL);

ShowWindow (hwnd,SW_SHOW);
UpdateWindow (hwnd);

while (!Done)
{
if (PeekMessage (&msg,hwnd,0,0,PM_REMOVE))
{

if (msg.wParam == WM_QUIT)
break;

TranslateMessage (&msg);
DispatchMessage (&msg);

}
else
{
if (Keys[VK_ESCAPE])
Done = true;
}

return 0

}



Metal Typhoon


[edited by - Metal Typhoon on August 13, 2002 12:09:13 AM]

Share this post


Link to post
Share on other sites
You're missing a '}' for the while loop. That final bracket is being used to close off the loop, so there is no other bracket to close off the function. Hence, the compiler unexpectedly reached the end of the file without finding another bracket.

EDIT: Damn my longer answer. I was beat.


[edited by - Erunama on August 13, 2002 12:11:12 AM]

Share this post


Link to post
Share on other sites
If you''re using Dev Studio, place the cursor on a { or } and hit Ctrl-]. It will take you to the brace it thinks is the matching one. 90% of the time, this will help you find problems like this.

-scott

Share this post


Link to post
Share on other sites