IAR error: a declaration cannot have a label
来源:互联网 发布:床垫品牌 知乎 编辑:程序博客网 时间:2024/05/22 06:48
原文:http://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement
[转]IAR error: a declaration cannot have a label
在使用switch时 在case 后面申请变量会出现 error: a declaration cannot have a label 的提示
原因:Case statements are only 'labels'. This means the compiler will interpret this as a jump directly to the label.The problem here is one of scope. Your curly brackets define the scope as everything inside the 'switch' statement. This means that you are left with a scope where a jump will be performed further into the code skipping the initialization. The correct way to handle this is to define a scope specific to that case statement and define your variable within it.
解决方法:在case 后面加一个{ }做相应的操作。
0 0
- IAR error: a declaration cannot have a label
- IAR error: a declaration cannot have a label
- a declaration cannot have a label
- 关于编译器提示a declaration cannot have a label的解决方法
- 关于编译器提示a declaration cannot have a label的解决方法
- [教你警告消除]Warning[Pe1072]: a declaration cannot have a label!
- IAR for MSP430 编译时出现Error[Pe099]: a declaration here must declare a parameter 错误
- error C2899: typename cannot be used outside a template declaration
- error: a label can only be part of a statement and a declaration is not a statement
- ERROR:a label can only be part of a statement and a declaration is not a statement
- 【C/C++】error: a label can only be part of a statement and a declaration is not a statement
- C语言:error: a label can only be part of a statement and a declaration is not a statement|
- error: a label can only be part of a statement and a declaration is not a statement
- Forward declaration of class cannot have a nested name specifier xcode 升级后cocos2d编译错误
- Error:SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
- error: declaration of ‘a’ as multidimensional array must have bounds for all dimensions except ...
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- Usb Audio Device Descriptor(2) Class-Specific Audio Control Interface Header Descriptor
- Apache优化:修改最大并发连接数
- Java基础之volatile,static,synchronized的区别
- 为data磁盘组删除其中一个盘(asm external data盘组中有两块盘)
- 使用Genymotion调试出现错误INSTALL_FAILED_CPU_ABI_INCOMPATI
- IAR error: a declaration cannot have a label
- javaEE之------SpringMVC中ResourceBundleViewResolver简单应用
- php读取超大日志文件
- poj 3304 Segments
- 【代码笔记】iOS-电影上的花絮,自动滚动
- TiDB:支持 MySQL 协议的分布式数据库解决方案
- 设置navigationbar的标题样式和背景颜色
- 图片选择器(支持相册和相机),只需一步实现
- GitHub详细教程