编译错误syntax error : missing ';' before 'type'
来源:互联网 发布:网络赚钱棋牌游戏 编辑:程序博客网 时间:2024/05/16 17:40
在vc中运行以下程序:
////////////////////////////////
//test.c
#include<stdio.h>
void main(void)
{
int i;
printf("Hello World/n");
int j;
}
将这个文件保存成了test.c
然后编译的时候会报一个错误:
syntax error : missing ';' before 'type'
仔细看起来所有的语法都似乎是对的,这个问题有点奇怪,如果把文件改成.cpp或者.cc则能正常编译,把“int j;”放在“printf("Hello World/n")”上也能正常编译。
google了下得到了答案和总结如下:
在VC中编译c程序,在一个大括号括起的范围内,如果变量声明放在了函数调用的后面,那么编译的时候就会报错:
syntax error : missing ';' before 'type'
然后你可以修改为把变量声明放在函数调用之前,就会顺利通过编译。
总结:
在VC中编译程序,如果是ANSI C或者C++,在可执行代码中随时定义变量是允许的,但是在C是不允许的。
这样的错误也体现在VS中,如果使用for (int i = 0; i++; i<10),且你的文件名是.c,编译时也会报错。
- 编译错误syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'原因探寻
- 编译错误syntax error : missing ';' before 'type'原因探寻
- 编译错误syntax error : missing ';' before 'type'原因探寻
- 编译错误syntax error : missing ';' before 'type'原因探寻
- vs2005 C编译错误syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'原因探寻
- VS编译错误:syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'原因探寻
- syntax error : missing ';' before 'type'错误
- syntax error : missing ';' before 'type'错误
- syntax error : missing ';' before 'type'
- syntax error : missing ';' before 'type'
- 编译错误syntax error : missing ';' before 'type'原因探寻(VS 编译C文件)
- VC编译C代码时错误“ syntax error : missing ';' before 'type' ”
- 常用算法经典代码(C++版)
- hdu 1969 Pie
- 使用 jQuery 避免鼠标双击
- Steps
- UVA 11987 Almost Union-Find
- 编译错误syntax error : missing ';' before 'type'
- VC条件断点和数据断点
- 猴子吃桃问题
- The Land of Justice
- 后缀数组论文题目
- How Many Points of Intersection?
- disassambe c++ source code
- Searching for Nessy
- [leetcode] Populating Next Right Pointers in Each Node