Code:
typedef enum { apple,orange, banana } fruit;
int main() {
fruit f = orange;
switch(f) {
case apple : printf("hello world\n");
return 0;
case orange : printf("it's orange \n");
return 0;
}
// unless you have return 0; here.
}
$ gcc -Wall -Wextra hello.c
hello.c: In function ‘main’:
hello.c:7:3: warning: enumeration value ‘banana’ not handled in switch
hello.c:14:1: warning: control reaches end of non-void function
If f is not apple or orange, Then control falls through(no default case) and compiler is right to say warning: control reaches end of non-void function.
Edit: you could add default: case to make compiler happy.