I'm only having a problem with a small part, i'm fairly new to computer programming and the program i'm using is Dev-C++. The part that i'm having a problem with is this:
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow);
;{
static WNDCLASS Wc;
memset(&Wc,0,sizeof(Wc));
static MSG Msg;
memset(&Msg,0,sizeof(Msg));
Wc.style=CS_HREDRAW | CS_VREDRAW;
Wc.lpfnWndProc=WndProc;
Wc.cbClsExtra=0;
Wc.cbWndExtra=0;
Wc.hInstance=hInst;
Wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
Errors:
54 C:\Users\Matthew\Dev-Cpp\Bouncing ball.cpp expected unqualified-id before '{' token
54 C:\Users\Matthew\Dev-Cpp\Bouncing ball.cpp expected `,' or `;' before '{' token
Line 54 is the problem and it's the ";{" line.
Please help me out with this problem, i honestly have no idea what i can do to fix it.
4 4112 Banfa 9,065
Expert Mod 8TB
Remove the ; at the end of the previous line and the beginning of that line 54.
Make sure you have include Windows.h (directly or indirectly).
Make sure you haven't #defined any symbols with clashing names.
That didn't fix the problem, here is all of the work i've done. -
#include <windows.h>
-
-
#define Show(Window) RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
-
[Linker error] undefined reference to `GetStockObject@4'
-
C:\Users\Matthew\AppData\Local\Temp\ccIveaaa.o(.text+0x350) In function `Z7WndProcP6HWND__jjl':
-
-
#define AppName "BouncingBall1"
-
#define Caption "Bouncing Ball ..."
-
-
char BCX_STR [1024*1024];
-
-
static int BCX_GetDiaUnit;
-
static int BCX_cxBaseUnit;
-
static int BCX_cyBaseUnit;
-
static int BCX_ScaleX;
-
static int BCX_ScaleY;
-
static HANDLE Form1;
-
-
double MIN (double,double);
-
double MAX (double,double);
-
-
int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
-
void FormLoad (HANDLE);
-
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
-
-
-
double MAX (double a, double b)
-
{
-
if (a > b)
-
{
-
return a;
-
}
-
return b;
-
}
-
-
-
double MIN (double a, double b)
-
{
-
if (a < b)
-
{
-
return a;
-
}
-
return b;
-
}
-
-
-
// standard main for Windows GUI
-
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
-
{
-
static WNDCLASS Wc;
-
memset(&Wc,0,sizeof(Wc));
-
static MSG Msg;
-
memset(&Msg,0,sizeof(Msg));
-
-
Wc.style=CS_HREDRAW | CS_VREDRAW;
-
Wc.lpfnWndProc=WndProc;
-
Wc.cbClsExtra=0;
-
Wc.cbWndExtra=0;
-
Wc.hInstance=hInst;
-
Wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
-
Wc.hCursor=LoadCursor(NULL,IDC_ARROW);
-
Wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
-
Wc.lpszMenuName=NULL;
-
Wc.lpszClassName=AppName;
-
RegisterClass(&Wc);
-
FormLoad(hInst);
-
// 50ms here, lower value gives higher speed
-
SetTimer((HWND)Form1,1,50,NULL);
-
// ye olde event message loop
-
while(GetMessage(&Msg,NULL,0,0))
-
{
-
if (!IsWindow((HWND)Form1)||!IsDialogMessage((HWND)Form1,&Msg))
-
{
-
TranslateMessage(&Msg);
-
DispatchMessage(&Msg);
-
}
-
}
-
return Msg.wParam;
-
}
-
-
-
// create the form and show it (somewhat older style)
-
void FormLoad (HANDLE hInst)
-
{
-
// get the scale factors
-
BCX_GetDiaUnit = GetDialogBaseUnits();
-
BCX_cxBaseUnit = LOWORD(BCX_GetDiaUnit);
-
BCX_cyBaseUnit = HIWORD(BCX_GetDiaUnit);
-
BCX_ScaleX = BCX_cxBaseUnit/4;
-
BCX_ScaleY = BCX_cyBaseUnit/8;
-
// now the form
-
Form1=CreateWindow(AppName,Caption,
-
DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU,
-
10*BCX_ScaleX,20*BCX_ScaleY,250*BCX_ScaleX,175*BCX_ScaleY,NULL,
-
(HMENU)NULL,(HINSTANCE)hInst,NULL);
-
Show((HWND)Form1);
-
}
-
-
-
// event message handler
-
LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
-
{
-
static HANDLE hBitmap;
-
static HBRUSH hBrush;
-
static HDC hdc;
-
static HDC hdcMem;
-
static int cxClient;
-
static int cyClient;
-
static int xCenter;
-
static int yCenter;
-
static int cxTotal;
-
static int cyTotal;
-
static int cxRadius;
-
static int cyRadius;
-
static int cxMove;
-
static int cyMove;
-
static int xPixel;
-
static int yPixel;
-
static int nScale;
-
-
while(1)
-
{
-
if (Msg == WM_CREATE)
-
{
-
hdc = GetDC(hWnd);
-
xPixel = GetDeviceCaps(hdc,ASPECTX);
-
yPixel = GetDeviceCaps(hdc,ASPECTY);
-
ReleaseDC(hWnd,hdc);
-
return 0;
-
break;
-
}
-
// draw the ball
-
if (Msg == WM_SIZE)
-
{
-
xCenter = (cxClient=LOWORD(lParam))/2;
-
yCenter = (cyClient=HIWORD(lParam))/2;
-
nScale = (int)MIN(cxClient*xPixel,cyClient*yPixel)/16;
-
cxRadius = nScale/xPixel;
-
cyRadius = nScale/yPixel;
-
cxMove = (int)MAX(1,cxRadius/4);
-
cyMove = (int)MAX(1,cyRadius/4);
-
cxTotal = 2*(cxRadius+cxMove);
-
cyTotal = 2*(cyRadius+cyMove);
-
if (hBitmap)
-
{
-
DeleteObject(hBitmap);
-
}
-
hdc = GetDC(hWnd);
-
hdcMem = CreateCompatibleDC(hdc);
-
hBitmap = CreateCompatibleBitmap(hdc,cxTotal,cyTotal);
-
ReleaseDC(hWnd,hdc);
-
SelectObject(hdcMem,hBitmap);
-
Rectangle(hdcMem,-1,-1,cxTotal+1,cyTotal+1);
-
hBrush = CreateHatchBrush(HS_DIAGCROSS,0);
-
SelectObject(hdcMem,hBrush);
-
SetBkColor(hdcMem,RGB(0,127,255));
-
Ellipse(hdcMem,cxMove,cyMove,cxTotal-cxMove,cyTotal-cyMove);
-
DeleteDC(hdcMem);
-
DeleteObject(hBrush);
-
return 0;
-
break;
-
}
-
// move the ball
-
if (Msg == WM_TIMER)
-
{
-
if (!hBitmap)
-
{
-
break;
-
}
-
hdc = GetDC(hWnd);
-
hdcMem = CreateCompatibleDC(hdc);
-
SelectObject(hdcMem,hBitmap);
-
BitBlt(hdc,xCenter-cxTotal/2,yCenter-cyTotal/2,cxTotal,cyTotal,hdcMem,0,0,SRCCOPY);
-
ReleaseDC(hWnd,hdc);
-
DeleteDC(hdcMem);
-
xCenter += cxMove;
-
yCenter += cyMove;
-
if (xCenter+cxRadius>=cxClient||xCenter-cxRadius<=0)
-
{
-
cxMove = -cxMove;
-
}
-
if (yCenter+cyRadius >= cyClient || yCenter-cyRadius <= 0)
-
{
-
cyMove = -cyMove;
-
}
-
return 0;
-
break;
-
}
-
// clean up and exit program
-
if (Msg == WM_DESTROY)
-
{
-
if (hBitmap)
-
{
-
DeleteObject(hBitmap);
-
}
-
KillTimer((HWND)Form1,1);
-
PostQuitMessage(0);
-
return 0;
-
}
-
break;
-
}
-
return DefWindowProc(hWnd, Msg, wParam, lParam);
-
}
-
About 200 lines and here are the new errors:
C:\Users\Matthew\AppData\Local\Temp\ccIveaaa.o(.te xt+0x100) In function `WinMain':
[Linker error] undefined reference to `GetDeviceCaps@8'
[Linker error] undefined reference to `GetDeviceCaps@8'
[Linker error] undefined reference to `DeleteObject@4'
[Linker error] undefined reference to `CreateCompatibleDC@4'
[Linker error] undefined reference to `CreateCompatibleBitmap@12'
[Linker error] undefined reference to `SelectObject@8'
[Linker error] undefined reference to `Rectangle@20'
[Linker error] undefined reference to `CreateHatchBrush@8'
And several others continuing along those lines of linker errors.
Banfa 9,065
Expert Mod 8TB
Actually that did fix the problem, its just that you had a second underlying problem that has now surfaced.
You program appears to compile where it didn't before but you now have linker programs (ignoring that fact that you seem to have a linker error embedded in the top of your code which I assume is a posting error).
"Undefined Reference" means that the linker was unable to resolve all the symbols in the program into addresses. In this case you have called functions that the linker can not find in any of you object files or any libraries that it is using.
Checking the help for GetDeviceCaps it seems likely that you have left gdi32.lib out of your linker command line, or if you are using an IDE then you have failed to specify it in the section for additional libraries.
So far all the functions I have checked have come from that library but if you add it and that does not resolve all the undefined symbols then look up those symbols that are still causing the error to see which library you need to include.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: erebus- |
last post by:
When learning the C programing languages, i have had and still am
having the problem of not being able to find answers to many
questions. Is their an overall guide/reference that someone knows?
|
by: CJack |
last post by:
hy,
I have an mdi application, i create a child form and I want to know
when a button is pressed while that child form is loaded.
I have this code:
private void frmTestBaby_KeyUp(object sender,...
|
by: Nathan Alden |
last post by:
I've already searched Google. I've already asked people in IRC. I have still
not found a solution that works for me for this extremely discouraging
apparent bug in the SmtpMail class.
...
|
by: Eric Keij |
last post by:
Hi,
I've installed Windows XP Service Pack 2 and the latest .NET framework
service pack. The .NET framework version running is 1.1.4322.573. After
these updates we experience problems running...
|
by: dhnriverside |
last post by:
Hi peeps
Ok, I've got a web application running (lets call it MyApp, so its namespace
is MyApp). I've created a subdirectory within this application called
"secure", and made than an Application...
|
by: Asha |
last post by:
hello attach is a problem i'm having after deploying to the production
server. can someone please identify whats wrng with it?
all the required dll which was running on the development server was...
|
by: Gianfranco |
last post by:
Hi everybody,
First of all, sorry for my english if it isn't perfect ;-p
I have an error in an asp.net application.
I have win2003 server, with iis 6. I'm developping with visual studio...
|
by: Rob T |
last post by:
When I was using VS2003, I was able to compile my asp.net project locally on
my machine and copy it to the production server and it would run just fine.
I've now converted to VS2005. The project...
|
by: Tom |
last post by:
First, my thanks in advance to those who can help explain away this
mystery line of code.
Petzold is a great teacher and I appreciate his work; however, his
explanation about an extra line of...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |