sdl - Clang with C code: enumeration values not explicitly handled in switch -


i'm trying compile code clang 3.1 , option -weverything:

#include <stdio.h> #include <stdlib.h> #include <sdl/sdl.h>  sdl_surface* init(sdl_surface* screen);   int main() {     sdl_event event;     sdl_surface* screen = null;     int quit = 0;      screen = init(screen);     if (screen == null) {         return exit_failure;     }     while(quit == 0) {         while(sdl_pollevent(&event)) {             if( event.type == sdl_quit ) {                 quit = 1;             } else if( event.type == sdl_keydown ) {                 switch( event.key.keysym.sym ) {                     case sdlk_up: printf("up\n"); break;                     case sdlk_down: printf("down\n"); break;                     case sdlk_left: printf("left\n"); break;                     case sdlk_right: printf("right\n"); break;                     default: break;                 }             }         }     }     sdl_freesurface(screen);     sdl_quit();     return 0; }  sdl_surface* init(sdl_surface* screen) {     if( sdl_init(sdl_init_everything) == -1) {         return null;     }     screen=sdl_setvideomode(100,100,32,sdl_swsurface);     return screen; } 

the compiler returns me following warning

main.c:22:25: warning: 229 enumeration values not explicitly handled in switch: 'sdlk_unknown', 'sdlk_backspace',       'sdlk_tab'... [-wswitch-enum]                 switch( event.key.keysym.sym ) {                         ^ 

elsewhere i've read similar error messages , people solved adding default case, here can see it's there. compile code without single warning, , of course here without needing put 229 possible cases.

from link:

http://clang-developers.42468.n3.nabble.com/question-on-wswitch-enum-td4025927.html

compile (see comments possible change) -weverything -wno-switch-enum

docs gcc: http://gcc.gnu.org/onlinedocs/gcc/warning-options.html

-wswitch warn whenever switch statement has index of enumerated type , lacks case 1 or more of named codes of enumeration. (the presence of default label prevents warning.) case labels outside enumeration range provoke warnings when option used (even if there default label). warning enabled -wall.

-wswitch-enum warn whenever switch statement has index of enumerated type , lacks case 1 or more of named codes of enumeration. case labels outside enumeration range provoke warnings when option used.

the difference between -wswitch , option option gives warning omitted enumeration code if there default label.<<<


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -