What do I miss?.. I get 2 warnings. Please Help..

I'm writing a program in C++ Win32 and I was at the status bar creation .. when I build to see if it works, (and that's what it does), but I get 2 warnings..
This is the piece of the code that I got 2 warnings..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.
.
109
110 case WM_SIZE:
111            {
112                // Size status bar and get height
113                HWND hStatus;
114                RECT rcStatus;
115                int iStatusHeight;
116
117                hStatus = GetDlgItem(hWnd, IDC_STATUS);
118                iStatusHeight = rcStatus.bottom - rcStatus.top;
119            }
120 break;
121
.
.


||=== Build: Debug in Folder (compiler: GNU GCC Compiler) ===|
In function 'LRESULT WindowProcedure(HWND, UINT, WPARAM, LPARAM)
113|warning: variable 'hStatus' set but not used [-Wunused-but-set-variable]
115|warning: variable 'iStatusHeight' set but not used [-Wunused-but-set-variable]

||=== Build finished: 0 error(s), 2 warning(s) (0 minute(s), 1 second(s)) ===|
||=== Run: Debug in Folder (compiler: GNU GCC Compiler) ===|


I know is working perfectly but I wanna know why the compiler says that these variables are set but not in use..!?
Last edited on
Because you set them to a value bue never use them.
You aren't using them withing their scope and they obviously can't be used outside their scope.
What's the point of setting them if you aren't going to use them at some point?

If your program is "working perfectly" then you can simply delete all of case WM_SIZE since it does nothing.
Well... where in that code do you see anything using the value of hStatus? Where do you see anything using the value of iStatusHeight ?

You store values in those variables, but nothing uses those values before those variables go out of scope and get destroyed.
Last edited on
Ohhh thanks dutch .. you're right. I was writing another program when in that code I wrote even open and save file function and then the status bar suppose to shows me that I open file or save in the first part of the status bar and then the path of the file that was save or open.
True, true.. now it makes sens .. Thank you..!!!
Yahh Mikey .. I now I understand that if I don't use something is useless to write.
Thanks again... !!
You're welcome. Glad it helped!
Topic archived. No new replies allowed.