error: a label can only be part of a statement and a declaration is not a statement
来源:互联网 发布:购买域名后如何使用 编辑:程序博客网 时间:2024/05/21 07:07
在开发代码中使用switch出现的一个编译错误:
error: a label can only be part of a statement and a declaration is not a statement
代码片段如下所示:
switch(cmd) { case EDMA3_DRV_IOCTL_DMA_BUFFER_ALLOC: dma_buf_info_t *dma_buf_info = (dma_buf_info_t *)arg; if(NULL == dma_buf_info || NULL == dma_buf_info->buf_info) { RPT(RPT_ERR, "null pointer,err"); return -1; } for(i=0; i<dma_buf_info->num_buffers; i++) { dma_buf_info->buf_info[i].virtAddr_kernel_space = (uint8_t *)dma_alloc_coherent(NULL, dma_buf_info->buffer_size, (dma_addr_t *)&dma_buf_info->buf_info[i].phyAddr, GFP_KERNEL); if(0 == dma_buf_info->buf_info[i].phyAddr) { RPT(RPT_ERR, "alloc dma buffer,error!! phyAddr == 0"); return -1; } RPT(RPT_DBG, "Allocated DMA phy memory: Phy Address: 0x%llx Virtual Address :0x%p Size :0x%x successfull!!", dma_buf_info->buf_info[i].phyAddr, dma_buf_info->buf_info[i].virtAddr_kernel_space, (unsigned int)dma_buf_info->buffer_size); } break;
修改方法,在case 后加大括号将代码括起来,如下所示
switch(cmd) { case EDMA3_DRV_IOCTL_DMA_BUFFER_ALLOC: { dma_buf_info_t *dma_buf_info = (dma_buf_info_t *)arg; if(NULL == dma_buf_info || NULL == dma_buf_info->buf_info) { RPT(RPT_ERR, "null pointer,err"); return -1; } for(i=0; i<dma_buf_info->num_buffers; i++) { dma_buf_info->buf_info[i].virtAddr_kernel_space = (uint8_t *)dma_alloc_coherent(NULL, dma_buf_info->buffer_size, (dma_addr_t *)&dma_buf_info->buf_info[i].phyAddr, GFP_KERNEL); if(0 == dma_buf_info->buf_info[i].phyAddr) { RPT(RPT_ERR, "alloc dma buffer,error!! phyAddr == 0"); return -1; } RPT(RPT_DBG, "Allocated DMA phy memory: Phy Address: 0x%llx Virtual Address :0x%p Size :0x%x successfull!!", dma_buf_info->buf_info[i].phyAddr, dma_buf_info->buf_info[i].virtAddr_kernel_space, (unsigned int)dma_buf_info->buffer_size); } } break;
解决
0 0
- 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
- 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
- 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
- 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
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- switch引发的错误: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”解决方法
- 错误“a label can only be part of a statement and a declaration is not a statement”解决方法
- switch 错误:a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- 如何在CStatic控件的指定位置显示提示信息
- php开发之旅 一维数值数组
- 关于C++ const 的全面总结
- JS脚本不能执行
- hbase配置优化
- error: a label can only be part of a statement and a declaration is not a statement
- 大数相乘
- JSON的定义:
- ORACLE RMAN备份及还原
- Word Ladder leetcode
- hadoop大集群实施--比较实用的思路(设备选型、是否使用虚拟机、快速部署安装、自动复制节点等)
- GridView + Gallery 一起使用的demo
- 从最大似然到EM算法浅解
- 协方差特征 image feature 二阶pooling + ECCV12