[Devel] break is not allowed in switch statement?

Daniel-Constantin Mierla daniel at voice-system.ro
Mon Dec 12 11:24:10 CET 2005


Hello,

ok, I will take a look and fix it. I remember that the grammar is to 
have some actions inside the "case" statement.

Cheers,
Daniel

On 12/10/05 09:30, Juha Heinanen wrote:
> i tried the following switch statement:
>
> 		switch (retcode) {
> 			case 1:
> 				route(4);
> 				exit;
> 			case -1:
> 			case -3:
> 				setflag(20);
> 				break;
> 			default:
> 				break;
> 		};
>
> but got syntax error on the last break statement.  then i tried removed
> the last break, but got syntax error again.  so it looks like empty
> default case or default case having a single break statement is not
> allowed.
>
> then i tried to replaced default case with case -2, but that didn't help
> either if the only statement in a case is break:
>
> 			case -2:
> 				break;
>
> i finally got it working by removing case default or case -2 altogether,
> but i don't like how the code now looks like:
>
> 		switch (retcode) {
> 			case 1:
> 				route(4);
> 				exit;
> 			case -1:
> 			case -3:
> 				setflag(20);
> 				break;
> 		};
>
> it would be nice if openser switch statement would allow a case and
> default case where the only statement is break.
>
> -- juha
>
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
>
>   



More information about the Devel mailing list