Search code examples
cstm32keil

111-D Statement is unreachable on Return 0


int main(void) {

    TIM4_Init();
    setSysTick();

    while (1) {
        TIM4->CCR1 = 600;       // 600 == 0.6 ms  -> 0'
        Delay(700);

        TIM4->CCR1 = 1500;      // 1500 == 1.5 ms -> 90'
        Delay(700);

        TIM4->CCR1 = 2100;      // 2100 == 2.1 ms -> 150'
        Delay(700);
    }

    return 0; 
}

Above is part of the code I'm currently working on. I'm getting a warning saying that 'Statement is unreachable' at the Return 0, and I couldn't figure out why.


Solution

  • Delete return 0; :) The compiler will notice that there is no way to reach end of main(), and it will not generate warning for reaching the end of int function without the return