Path: utzoo!attcan!uunet!cs.utexas.edu!usc!wuarchive!emory!gatech!bloom-beacon!eru!hagbard!sunic!news.funet.fi!funic!fuug!tuura!risto From: risto@tuura.UUCP (Risto Lankinen) Newsgroups: comp.lang.c Subject: Rules in placement of 'case'-labels Message-ID: <808@tuura.UUCP> Date: 16 Oct 90 12:34:57 GMT Distribution: comp Organization: Nokia Data Systems Oy Lines: 39 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@yj.data.nokia.fi ***************************************