错误提示:
Errer:initialization of 'model' is skipped by 'case' label
思路:从网上总结之后,得出解决方法,如下:
具体解决:
是这段代码:
switch(lbgbuff[x].linbtn->btnType)
{
case BTNTYPE_COMBINATION_CONTROL://集控按钮处理!
SmartHomeModel* model; //选中的操作
WORD count = 0; //集控按钮操作中的目标数
//----------------------------------------------发送数据!!!!
if (lbgbuff[x].prCount)//长按或单击状态!
{
count = lbgbuff[x].linbtn->model2Count;
model = lbgbuff[x].linbtn->m_pModel2;
}
else
{
count = lbgbuff[x].linbtn->modelCount;
model = lbgbuff[x].linbtn->m_pModel;
}
if (count > 0)
{
ClearMessageList();//清除消息队列
for (WORD i = 0; i < count; i++)
{
SendSmartHomeMsg(model[i], FALSE, lbgbuff[x].linbtn->btnId);//发送按钮当前操作中的所有操作目标
printf("lsjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\r\n");
}
}
break;
在switch- case中,定义了变量。改进方法是在case中加上{}括号。还可以将switch- case模式改成if-else模式也可以解决此问题。