#a label can only be part of a statement and a declaration is not a statement
#問題現(xiàn)象
xxxxxxxxx.c:2697:5: error: a label can only be part of a statement and a declaration is not a statement
? ? struct v4l2_input input1;
? ? ^~~~~~
xxxxxxxxx.c:2698:5: error: expected expression before ‘int’
? ? int index;
? ? ^~~
#問題分析
case 之后的’A’為一個label,隨后定義的變量由于沒有明確的作用域而會報錯莽龟。
#處理方法
將此case的處理內(nèi)容用{}包括起來锨天;
將變量定義到switch之外毯盈。
#問題衍生
在switch里面病袄,case之外,不要定義變量益缠,因為這些語句都會被忽略,進(jìn)入switch后會直接尋找case幅慌,而忽略其它語句。