What is the meaning of the GCC warning "case label value exceeds maximum value for type"?
Well, KEY_F(9) would be 273 (see curses.h) which exceeds the range of char (-128,127).
A char is a number between -128 and 127. KEY_F(9) probably is a value outside of that range.
Use:
- unsigned char, or
- int, or
- (char) KEY_F(9)
Or even better, use a debugger and determine sizeof(KEY_F(9)) to make sure it's a byte and not a short.
In this case, KEY_F(9)
is evaluating to something outside the range of char
. The switch
statement is assuming that because its argument is a char
, that all case labels will be also. Changing the switch
to read switch((unsigned int)ch)
will cure it.