>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >Sent: 17 February 2005 16:34 >To: Microcontroller discussion list - Public. >Subject: Re: [EE] Languages, was Bug in Microchip mcc18 std library? > > >>> I would agree with your assessment, but the other part that >I cannot >>> figure, is why have a switch statement? It does nothing except fall >>> straight through >>> to the default case. >> >>It doesn't for the numbers 0..9. > >Hang on, there is no mention of code between the switch, and >the default, so I imagine that is all empty. Hence the switch >statement will generate a label to the default, which will >always be executed, and in my mind the code generated by the >switch statement should be optimised out by the compiler for >this reason. Hence the code becomes an if ... else ... >construct only, which as Wouter noted handles 0..9. There is >no code to handle cases outside these numbers at all. > >what have I missed ? The compiler can still "see" the case statements, within the switch block, even though they are within an if-else statement. FWIW I tried this in the HiTech PICC compiler and it compiles cleanly and works correctly ( once the syntax errors are fixed). Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist