当前位置:网站首页>error: ‘for‘ loop initial declarations are only allowed in C99 mode
error: ‘for‘ loop initial declarations are only allowed in C99 mode
2022-07-20 00:00:00 【墨痕诉清风】
现象
今天在使用 gcc 编译代码时报出:
error: 'for' loop initial declarations are only allowed in C99 mode
note: use option -std=c99 or -std=gnu99 to compile your code
原因
编译出错,这是因为在gcc中直接在for循环中初始化了增量:
for(int i=0; i<len; i++)
{
}
第一种方法
这语法在gcc中是错误的,必须先先定义i变量:
int i;
for(i=0;i<len;i++)
{
}
这是因为 gcc 基于 c89 标准,若换成 c99 标准就可以在 for 循环内定义i变量了。
第二种解决方法
就是在可写 makefile 编译指令时,将 gcc for.c -o for.out
改为 gcc -std=c99 for.c -o for.out
边栏推荐
- Why do you say that the maximum single table of MySQL database is 20million? Based on what?
- 什麼是複制沖突
- 144. 二叉树的前序遍历
- 股票开户网上办理的话安全吗。股票开户去哪里。
- Introduction to kubernetes components
- Maintainability of data intensive application of reading notes
- flv.js加载视频流
- 《PyTorch深度学习实践》学习笔记:循环神经网络(基础篇)
- 中国大陆IP段(含港澳)【2022-07-15】
- Which platform is the best and safest to buy stocks on?
猜你喜欢
重新认识生命世界,也重新认识我们自己
Portuguese financial Vocabulary Translation
COLA 4.0 - DDD项目实践
没有了可用Task slot,Flink新增任务会怎样?
FAQ丨构建业务安全平台架构,你想要的答案都在这里!
读书笔记之数据密集型应用的可维护性
MySQL 5.7 is about to stop and only maintain. It's time to learn a wave of MySQL 8
洛谷P1955 程序自动分析
App application testing methods and testing ideas
Alipay fund. trans. uni. Function integration of transfer (single transfer interface)
随机推荐
Zero Path
关于 SAP UI5 对服务器端渲染 Server Sider Render 的支持问题
App application testing methods and testing ideas
Awk statistical average max min
SAP Spartacus 产品明细页面的 url 设计和数据源
根据二叉树的中序和后续遍历
Is it safe to choose online stock account opening in Hangzhou and Wuhan?
. Net uses its own Di batch injection service and backgroundservice
Revit (22) familyinstance common API encapsulation
读书笔记之数据密集型应用的可维护性
AI常用框架和工具丨13. PyTorch实现基于CNN的手写数字识别
Nexttick stuff
Unable to install cloudera manager agent
.NET 设置Socket 对象的“TFO”快速打开连接选项(跨平台兼容的)
Read through the white paper on business security - four trends in the future
Test / development programmer Xiao Zhang's blind date
将流转化为数据产品
为什么大家说mysql数据库单表最大两千万?依据是啥?
Zero Path
MySQL 5.7都即将停只维护了,是时候学习一波MySQL 8了