Rules in placement of 'case'-labels
Risto Lankinen
risto at tuura.UUCP
Tue Oct 16 22:34:57 AEST 1990
Hi!
I've found that the following construct compiles without errors at least
in Microsoft C version 6.0 (sorry, the scandinavian keyboard inhibits some
crucial characters in favor to special alphabets) :
DoThis( ... )
(
switch( ... )
(
case 1:
for( ... )
(
DoSomething1();
/* Note, the 'case' label below is inside an open statement block */
case 2:
DoSomething2();
)
break;
...
)
)
Weird, isn't it? It also made me wonder whether it is legal in C . I can
think of a few practical uses for it in Windows programming, where code size
is a concern.
However, if this is a legal construct, it introduces an inconsistency: You
can replace the 'for' by 'if', 'while', 'do' or just a simple statement block
without any flow-control keyword. But you cannot substitute another 'switch'
in similar manner, because the label will then belong to the inner of the two
switches.
Terveisin: Risto Lankinen
--
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept * 2 2 *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME! Now working on 2 +1 *
replies: risto at yj.data.nokia.fi ***************************************
More information about the Comp.lang.c
mailing list