[Devel] break is not allowed in switch statement?

Juha Heinanen jh at tutpro.com
Sat Dec 10 08:30:34 CET 2005


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



More information about the Devel mailing list