Background
I am trying to assign -1 to an enum variable as shown below:
typedef enum test {
first,
second,
}soc_ctr_type_t
soc_ctr_type_t ctype;
...
switch(type){
case 1:
ctype = first;
break;
case 2:
ctype = second;
break;
default:
ctype = -1;
}
If type is the default case, ctype should become -1, but it's not.
When I use printf to debug, ctype is 255.
Question
Why does ctype become 255 instead of -1?