VS 2010错误代码C2143: 语法错误 : 缺少“;”(在“类型”的前面) 解决方法
2018-01-27 16:06
1621 查看
使用VS2010编译C源码的时候碰到了这个问题, 据说C++ 不会有问题, 还没验证过.
出错代码:
报错的是第15行, 试了赋值和声明分开, 也不行.
解决方法:
把pddata的声明放在main()最开始, 问题消失. 如下:
int main()
{
unsigned char *pddata = NULL;
char *str_num = "20171023";
int width = 176;
int height = 144;
int len = width*height*3/2;
FILE *fp = fopen("E://c.yuv","wb");
if (fp == NULL)
{
printf("fp null\n");
return 0;
}
pddata = (unsigned char*)malloc(len);
/*...为了方便看,这一部分省略了...*/
}
出错代码:
int main() { char *str_num = "20171023"; int width = 176; int height = 144; int len = width*height*3/2; FILE *fp = fopen("E://c.yuv","wb"); if (fp == NULL) { printf("fp null\n"); return 0; } unsigned char *pddata = (unsigned char*)malloc(len); /*...为了方便看,这一部分省略了...*/ }
报错的是第15行, 试了赋值和声明分开, 也不行.
解决方法:
把pddata的声明放在main()最开始, 问题消失. 如下:
int main()
{
unsigned char *pddata = NULL;
char *str_num = "20171023";
int width = 176;
int height = 144;
int len = width*height*3/2;
FILE *fp = fopen("E://c.yuv","wb");
if (fp == NULL)
{
printf("fp null\n");
return 0;
}
pddata = (unsigned char*)malloc(len);
/*...为了方便看,这一部分省略了...*/
}
相关文章推荐
- VS2010 语法错误: 标识符“__RPC__out_xcount_part” 解决方法
- C++ MySQL编译错误 error C2146: 语法错误 : 缺少“;”(在标识符“fd”的前面) 解决方法
- 解决C2143语法错误: 缺少“;”(在“<end Parse>”的前面)
- VS2010 语法错误: 标识符“__RPC__out_xcount_part” 解决方法
- 类语句.NET下编译C++代码时出现"error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int"错误的解决方法。
- .NET下编译C++代码时出现"error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int"错误的解决方法。
- error C2143: 语法错误 : 缺少“{”(在“:”的前面)编译错误的解决
- error C2146: 语法错误 : 缺少“;”(在标识符“PVOID64”的前面) 如何解决
- error C2143:语法错误 : 缺少“;”(在“类型”的前面)的解决方案
- error C2143: 语法错误 : 缺少“{”(在“:”的前面)编译错误的解决
- 解决“ .dll(或.ocx)控件已加载,但对DllregisterServer的调用失败,错误代码为0x80004005”问题的两种终极方法:SubInACL安装 VS 命令提示符
- VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403...的解决方法
- error C2146: 语法错误 : 缺少“;”(在标识符“PVOID64”的前面) 如何解决
- [iOS]Xcode解决代码高亮、语法提示、错误警告等功能失效的解决方法
- libnids 在VS 2010中使用方法及编译错误解决方法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认int 错误的解决方法
- 语法错误 : 缺少“;”(在“类型”的前面)的解决方案
- 语法错误 : 缺少“;”(在“类型”的前面)的解决方案
- error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 错误的解决方法