This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

In a switch-case-break statement, if I don't break, it should "fall through" to the next case. Why doesn't this happen?

Hi - this is a compiler/coding question.

Usually if there's no break at the end of the case, the program should "fall through" to the next case.

I ignored the warning (which is good - in case I may have overlooked the fact that there's no break) but I see that the compiler adds in its own break and doesn't allow the "fall through". Is there any way to have it fall-though? This will save unnecessary repeating of code. (Code snippet below.)

Thanks,

Mechi

switch(status)
{
case BUTTON_IDLE:
    if ((sTime.systemTicks - sButton.up_time) < BUTTON_IDLE_TIME)
       break;
// else fall thru
case BUTTON_WAIT_FOR_PRESS:
    sButton.up_time = sTime.systemTicks;
    sButton.up_status = BUTTON_PRESSED;
    break;

}

**Attention** This is a public forum