for’ loop initial declarations are only allowed in C99 mode
2016-03-18 14:13
465 查看
使用gcc编译代码是报出error: 'for' loop initial declarations are only allowed in C99 modenote: use option -std=c99 or -std=gnu99 to compile your code错误,这是因为在gcc中直接在for循环中初始化了增量:
[cpp] view plain copy
for(int i=0; i<len; i++) {
}
这语法在gcc中是错误的,必须先先定义i变量:
[cpp] view plain copy
int i;
for(i=0;i<len;i++){
}
这是因为gcc基于c89标准,换成C99标准就可以在for循环内定义i变量了:gcc src.c -std=c99 -o src
[cpp] view plain copy
for(int i=0; i<len; i++) {
}
这语法在gcc中是错误的,必须先先定义i变量:
[cpp] view plain copy
int i;
for(i=0;i<len;i++){
}
这是因为gcc基于c89标准,换成C99标准就可以在for循环内定义i变量了:gcc src.c -std=c99 -o src
相关文章推荐
- Node.js事件循环(Event Loop)和线程池详解
- JavaScript运行机制之事件循环(Event Loop)详解
- linux 制作大容量文档解决容量过大的问题
- Message Looper Handler三者之间的关联
- linux脚本之 for循环方式
- mount 带有分区的loopback设备
- Initial
- LeetCode:Linked List Cycle
- LeedCode:Linked List Cycle II
- Eclipse编辑java文件报Unhandled event loop exception错误的解决办法
- CPP-vector erase while looping
- c 实现的 循环队列
- mysql while,loop,repeat循环,符合条件跳出循环
- 理解Handler、Looper、MessageQueue、Thread关系
- 《汇编语言(王爽)》第五章([bx]和loop指令)、第六章(包含多个段的程序)【总结】
- Run Loop 总结
- Run Loop 详解1
- Google Earth For Javascript 初始化
- Rust猜数字之循环
- 8086中的jmp相关指令