Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 846 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
switch...case without break; #330463
06/27/10 19:03
06/27/10 19:03
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
I found out that in Lite-C, a switch...case without break doesn't behave like in standard C/C++. You can see that in this example:

Code:
#include <acknex.h>

var x;
void main ()
{
	while (1)
	{
		x = 0;
		switch(key_lastpressed)
		{
			case 16: // q
			x += 1;
			case 17: // w
			x +=10;
			case 18: case 19: // e or r
			x+=100;
			break;
		}
		wait(1);
	}
}

PANEL* debug_pan =
{
	digits(10,10,"%f",*,1,x);
	flags = SHOW;
}



In standard C/C++, the code shouldn't be stopped being executed if there is no break, but a new case. This means, when you press Q, x should be 111, but it's 1! It seems that Lite-C stops at the next case. But the E and R key behave the same, so it seems that it doesn't stop if there is no code inbetween. If this is some kind of "noob-protection", in case the user forgot a break; please make a define or something to turn it off.

Also, an empty switch...case, like this
Code:
switch(something)
{

}


returns a syntax error. It also returns a syntax error if there is only a default case. It would be nice if the compiler didn't give an error, because sometimes it can be useful to comment out some cases for debugging and it's just annoying if you comment out the last not commented case and you get an error and have to comment out the whole switch.


This happens with 7.85 and 8.00.6.

Re: switch...case without break; [Re: Lukas] #347835
11/19/10 20:57
11/19/10 20:57
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Bump.

Re: switch...case without break; [Re: Lukas] #348076
11/22/10 14:40
11/22/10 14:40
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks, I have somehow overlooked this.

There seems indeed something to be non-standard with switch/case. We'll check if this can be corrected quickly, otherwise it will be documented.

Re: switch...case without break; [Re: jcl] #348082
11/22/10 15:54
11/22/10 15:54
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Ok, thanks.

Re: switch...case without break; [Re: Lukas] #350028
12/13/10 11:49
12/13/10 11:49
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Any news about this?

Re: switch...case without break; [Re: Lukas] #350034
12/13/10 12:23
12/13/10 12:23
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
We have a list of similar small issues for the compiler - they'll all be addressed when the next compiler improvement step is due.

Re: switch...case without break; [Re: jcl] #350041
12/13/10 13:31
12/13/10 13:31
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Ok...


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1