error C2143: syntax error : missing ';' before 'type'
2014-12-25 15:26
405 查看
转转自:点击打开链接(有问题可以告知删除)
近来写程序时发现了一个问题,用 VC 编译 C语言是 总是提示一个错误:error C2143: syntax error : missing ';' before 'type'。考虑了很久也没有答案,于是上网搜索,终于在一位网友网易博客中找到了解决办法。解决方法如下:
把所有变量的声明放在可执行代码之前。
出现此问题的原因在于:将文件保存成了 *.c 格式。如果是 cpp 格式就能正常编译。
这是因为:在 ANSI C 或者 C++中,在可执行代码中随时定义变量是允许的,但是在K&R C中是不允许的,因此才会出现这个错误。VC6.0 、VS2008 都是用的 K&R C 来实现 C语言的,因此编译过程中会报错。
近来写程序时发现了一个问题,用 VC 编译 C语言是 总是提示一个错误:error C2143: syntax error : missing ';' before 'type'。考虑了很久也没有答案,于是上网搜索,终于在一位网友网易博客中找到了解决办法。解决方法如下:
把所有变量的声明放在可执行代码之前。
出现此问题的原因在于:将文件保存成了 *.c 格式。如果是 cpp 格式就能正常编译。
这是因为:在 ANSI C 或者 C++中,在可执行代码中随时定义变量是允许的,但是在K&R C中是不允许的,因此才会出现这个错误。VC6.0 、VS2008 都是用的 K&R C 来实现 C语言的,因此编译过程中会报错。
相关文章推荐
- KR C vs ANSI C (error C2143: syntax error : missing ';' before 'type' in Visual Studio 2008)
- 【VC6.0】error C2143: syntax error : missing ';' before 'type'
- VC++中编译C出错:error C2143: syntax error : missing ';' before 'type'
- VC++中编译C出错:error C2143: syntax error : missing ';' before 'type'
- K&R C vs ANSI C (error C2143: syntax error : missing ';' before 'type' in Visual Studio 2008)
- VC++中编译C出错:error C2143: syntax error : missing ';' before 'type'
- VC++ 2005中编译C出错:error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type' in Visual C++
- 奇怪的 error C2143: syntax error : missing ';' before 'type'
- 关于C++程序编译出现error C2143: syntax error : missing ';' before 'type'的解决办法
- K&R C vs ANSI C (error C2143: syntax error : missing ';' before 'type' in Visual Studio 2008)
- VC++ 2005中编译C出错:error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ';' before 'type'
- 关于C++程序编译出现error C2143: syntax error : missing ';' before 'type'的解决办法
- error C2143: syntax error : missing ';' before 'type'
- error C2143: syntax error : missing ‘;’ before ‘type’
- VC6.0 error C2143: syntax error : missing ';' before 'type'。。