分类: C/C++
2009-04-30 14:27:25
我在编译我的例子时,在模拟器上编译没有问题。但转到release环境时,编译失败。
出现
error: jump to case label
这种错误,提示问题出现在下面这段代码上
switch(aIndicatorIconType)
{
case EIndicatorIconEmpty:
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick_mask);
break;
case EIndicatorIconAppActive:
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTock);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTock_mask);
break;
case EIndicatorIconAppInactive:
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick_mask);
break;
default:
break;
}
在网上 google 了一下,说明没可在每个 case 上加括号引起的。
将代码改为 :
switch(aIndicatorIconType)
{
case EIndicatorIconEmpty:{
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick_mask);
}
break;
case EIndicatorIconAppActive:{
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTock);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTock_mask);
}
break;
case EIndicatorIconAppInactive: {
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmTestbitmapTick_mask);
}
break;
default:
break;
}
测试通过。希望对遇到这个问题的朋友能有所帮助。:)