is there any possible problems that can arise from too many error messages? On my current project I am getting 7 warnings 5 from unused parameters and 2 from possible use before declaration. Are there any problems that this can cause?
is there any possible problems that can arise from too many error messages? On my current project I am getting 7 warnings 5 from unused parameters and 2 from possible use before declaration. Are there any problems that this can cause?
Usually they are there for a reason......
Its hard to tell what may happen without seeing anything specific...
Post some code....
> 5 from unused parameters
This is just clutter - it won't do any harm, but it should be tidied up at some point
> 2 from possible use before declaration
You mean use before initialisation?
This is potentially serious
Now you and I know that this is OK, because foo is only allocated and used if n > 0. However, the compiler might not be able to tell this.Code:int *foo; if ( n > 0 ) { foo = malloc( n * sizeof(int) ); } for ( i = 0 ; i < n ; i++ ) { foo[i] = 0; }
A more complex example might leave you with a possible path through the code to where a variable might be used before being initialised, and at that point, your code is broken.
How should I "tidy up" the unused parameters?
Yes i meant before initation. This is where Im getting those errors:
BOOL CALLBACK PointSelProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
int xpoint, ypoint;
switch (message)
{
case WM_INITDIALOG :
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
hdc=GetDC(hwnd) ;
SelectObject (hdc, GetStockObject (BLACK_BRUSH)) ;
Ellipse(hdc, xpoint - 5, ypoint + 5, xpoint + 5, ypoint - 5);
ReleaseDC(hwnd, hdc) ;
return TRUE ;
case IDCANCEL :
EndDialog (hDlg, 0) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
The variables xpoint and ypoint are edit boxes in the dialog box. The user changes the values presses OK and the computer will draw a elipse to signalfy a point (its a graphing prog).
Should I be worried or is it just "clutter"?
There's not a lot you can do about the unused parameters - I take it that it's part of the standard interface.
Something like
lParam = lParam;
Sometimes works at keeping the compiler happy. You may find you use more of them as the code expands.
> int xpoint, ypoint;
But how are these initialised?
You've mentioned a dialog box, but even if that's handled inside this function, it's going to be a different message (and hence a different invocation of this function). If this is so, then xpoint will contain fresh random garbage each time the function is called.
If you want these vars to remember the dialog values in one message, and be used in the next message which draws the ellipse, then you need to make these static, like
static int xpoint, ypoint;
That is the dialog box procedure. Should they still be static? And your right with the parameters they are just part of the Windows and Dialog boxes standard procedures.
> That is the dialog box procedure
No idea - repost more code on the windows board - I can't help with the details....
Ok...I'll post a thread on the windows board call "Warning messages"
Just give me a couple of sec to post post it
i'd imagine any programmer defined functions can be bulletproofed against these kinds of warnings... [i used to leave the warnings be, but in the end it's better practice...] and i would also imagine that the compiler's libraries were designed such that no warnings [let alone errors] would occur with correct linkage to all said libraries...
hasafraggin shizigishin oppashigger...
most compilers support pragmas of this sort since its part of the standard though i don't know what the syntax and use rules are... check the compiler doc's ir something if these don't work.
#pragma warning(disable:errornumberhere)
// Code Segment...
#pragma warning(default:errornumberhere)
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.