When a variable is declared in one case, the next case technically remains in the same scope, so you can reference it there, but if you click on this case without hitting it first, you will end up calling an uninitialized variable. This error prevents this.
All you have to do is either define it before the switch statement, or use curly braces {} to make sure that it goes out of scope before exiting a specific case.
switch (msg) {case WM_PAINT: {HDC hdc; hdc = BeginPaint (hWnd, & ps); }
Leninkumar
source share