Compiler erros make no sense?

Hello, me again :p. Im was following [url=http://www.aaroncox.net/tutorials/arcade/FallingBlocks.html] this [/url] tutorial and when i finished i went to compile, and i got these errors. Alot of them make no sense like, " Cannot convert from SDL_Rect to SDL_Rect ". And, "temp is skipped by 'case' label".

in the switch statement its talking about the case statements look the same besides different case names and different colors.
1
2
3
4
5
6
case SQUARE_BLOCK:
		SDL_Rect temp = { RED_SQUARE_X, RED_SQUARE_Y, 
						  SQUARE_MEDIAN * 2, SQUARE_MEDIAN * 2 };

		source = temp;
		break;



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
1>  main.cpp
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(54): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(55): error C2374: 'temp' : redefinition; multiple initialization
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(57): error C2440: '=' : cannot convert from 'SDL_Rect' to 'SDL_Rect'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(60): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(55) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(60): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(61): error C2374: 'temp' : redefinition; multiple initialization
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(63): error C2440: '=' : cannot convert from 'SDL_Rect' to 'SDL_Rect'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(66): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(61) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(66): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(55) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(66): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(67): error C2374: 'temp' : redefinition; multiple initialization
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(69): error C2440: '=' : cannot convert from 'SDL_Rect' to 'SDL_Rect'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(72): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(67) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(72): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(61) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(72): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(55) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(72): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(73): error C2374: 'temp' : redefinition; multiple initialization
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(75): error C2440: '=' : cannot convert from 'SDL_Rect' to 'SDL_Rect'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(78): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(73) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(78): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(67) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(78): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(61) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(78): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(55) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(78): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(79): error C2374: 'temp' : redefinition; multiple initialization
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(48) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(81): error C2440: '=' : cannot convert from 'SDL_Rect' to 'SDL_Rect'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(84): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(79) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(84): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(73) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(84): error C2360: initialization of 'temp' is skipped by 'case' label
1>          c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(67) : see declaration of 'temp'
1>c:\users\david\documents\visual studio 2010\projects\falling blocks\csquare.h(84): error C2360: initialization of 'temp' is skipped by 'case' label
I can't say about "cannot convert from 'SDL_Rect' to 'SDL_Rect' ", but the others are because you can't declare things plainly in a switch. You need to wrap them in {} to fix scope problems. The thing is that only {} can show scope, and if you declare variables in cases, they are all sort of in the same scope, but some of them are never constructed, so it's a mess.
thanks that fixed it!
Topic archived. No new replies allowed.