Error C2360: Initialization of 'hdc' is skipped by 'case' label

Cubi73

Where is the huge difference, which generates error C2360, in following two definitions?

switch (msg) {
    case WM_PAINT:
        HDC hdc;
        hdc = BeginPaint(hWnd, &ps); // No error
        break;
}

and

switch (msg) {
    case WM_PAINT:
        HDC hdc = BeginPaint(hWnd, &ps); // Error
        break;
}
Alan Stokes

The first is legal and the second isn't. Skipping a declaration without an initializer is sometimes allowed, but never one with an initializer.

See Storage allocation of local variables inside a block in c++.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

initialization of 'unused' is skipped by 'goto label' - why do I get it for std::string but not for int?

From Dev

initialization of 'unused' is skipped by 'goto label' - why do I get it for std::string but not for int?

From Dev

crosses initialization error in switch case statement

From Dev

C initialization bus error

From Dev

Case being skipped and sent to catch?

From Dev

Label animation inside a switch case c#

From Dev

error: an enum switch case label must be the unqualified name of an enumeration constant

From Dev

switch statement Error : Statement must be prepended with case label

From Dev

Exception catch clause skipped for an error?

From Dev

Initialization error

From Dev

error: initialization with "{...}" expected for aggregate object - c++

From Dev

C++ error: no matching constructor for initialization of

From Dev

C - filling struct after initialization - compilation error

From Dev

Error during Dynamic Initialization of Array in C

From Dev

Eager initialization vs Lazy initialization use case

From Dev

java - duplicate case label

From Dev

Java - duplicate case label

From Dev

C - User input getting skipped?

From Dev

scanf function seems to be skipped in c

From Dev

HDC memory leak (release HDC/ delete hdc)

From Dev

BeginInvoke causes error due to skipped null check

From Dev

Calculator: error No such file or directory, skipped frames

From Dev

duplicate case label in case 79-70

From Dev

local variable initialization error

From Dev

bookshelf and knex initialization error

From Dev

Flurry initialization error with Android

From Dev

arraylist initialization error

From Dev

Strange variable initialization error

From Dev

Entity Framework error initialization

Related Related

  1. 1

    initialization of 'unused' is skipped by 'goto label' - why do I get it for std::string but not for int?

  2. 2

    initialization of 'unused' is skipped by 'goto label' - why do I get it for std::string but not for int?

  3. 3

    crosses initialization error in switch case statement

  4. 4

    C initialization bus error

  5. 5

    Case being skipped and sent to catch?

  6. 6

    Label animation inside a switch case c#

  7. 7

    error: an enum switch case label must be the unqualified name of an enumeration constant

  8. 8

    switch statement Error : Statement must be prepended with case label

  9. 9

    Exception catch clause skipped for an error?

  10. 10

    Initialization error

  11. 11

    error: initialization with "{...}" expected for aggregate object - c++

  12. 12

    C++ error: no matching constructor for initialization of

  13. 13

    C - filling struct after initialization - compilation error

  14. 14

    Error during Dynamic Initialization of Array in C

  15. 15

    Eager initialization vs Lazy initialization use case

  16. 16

    java - duplicate case label

  17. 17

    Java - duplicate case label

  18. 18

    C - User input getting skipped?

  19. 19

    scanf function seems to be skipped in c

  20. 20

    HDC memory leak (release HDC/ delete hdc)

  21. 21

    BeginInvoke causes error due to skipped null check

  22. 22

    Calculator: error No such file or directory, skipped frames

  23. 23

    duplicate case label in case 79-70

  24. 24

    local variable initialization error

  25. 25

    bookshelf and knex initialization error

  26. 26

    Flurry initialization error with Android

  27. 27

    arraylist initialization error

  28. 28

    Strange variable initialization error

  29. 29

    Entity Framework error initialization

HotTag

Archive