[Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode 解决方法

简介: [Error] ‘for’ loop initial declarations are only allowed in C99 or C11 mode[Note] use option -std=c99,-std=gnu99,-std=c11 or-std=gnu11 to compile your code

一、异常


编写C语言程序遇到如下异常,不能成功编译运行程序

使用 GCC 编译代码是报出

[Error] ‘for’ loop initial declarations are only allowed in C99 or C11 mode

[Note] use option -std=c99,-std=gnu99,-std=c11 or-std=gnu11 to compile your code


二、解决方法


错误,这是因为在 GCC 中直接在 for 循环中初始化了增量:


这种写法在 GCC 中是错误的,必须先定义变量i,然后可以成功编译运行。


也可以将 GCC 换成 C99 标准就可以在 for 循环内定义 i 变量了。


gcc src.c -std=c99 -o src


目录
相关文章
|
5月前
|
测试技术
Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded 的解决办法
Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded 的解决办法
225 0
|
数据安全/隐私保护
Do Sync Disk 0 Part 0 Failed, code=S3_F42, msg=Sync Failed after retry 5 times
Do Sync Disk 0 Part 0 Failed, code=S3_F42, msg=Sync Failed after retry 5 times
181 1
|
索引
ES报错:“type“=>“cluster_block_exception“, “reason“=>“blocked by: [FORBIDDEN/12/index read-only / allow
ES报错:“type“=>“cluster_block_exception“, “reason“=>“blocked by: [FORBIDDEN/12/index read-only / allow
343 0
ES报错:“type“=>“cluster_block_exception“, “reason“=>“blocked by: [FORBIDDEN/12/index read-only / allow
|
网络安全 Windows
解决adb报错“failed to create fdevent interrupt socketpair: Invalid argument“问题
解决adb报错“failed to create fdevent interrupt socketpair: Invalid argument“问题
336 0
解决adb报错“failed to create fdevent interrupt socketpair: Invalid argument“问题
飞思卡尔codewarrior下载出现USBD connection error:Failed to connect to targe(Reason :Target reset pin time out)
飞思卡尔codewarrior下载出现USBD connection error:Failed to connect to targe(Reason :Target reset pin time out)
飞思卡尔codewarrior下载出现USBD connection error:Failed to connect to targe(Reason :Target reset pin time out)
|
Java Android开发
is not allowed for source level below 1.7 的解决办法
is not allowed for source level below 1.7 的解决办法
180 0
运行 ‘ApiApplication‘ 出错: Command line is too long. Shorten command line for ShopApiApplication or
运行 ‘ApiApplication‘ 出错: Command line is too long. Shorten command line for ShopApiApplication or
226 0
运行 ‘ApiApplication‘ 出错: Command line is too long. Shorten command line for ShopApiApplication or
|
C语言
解决Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
679 0
解决Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
|
C语言
[Error] ‘for‘ loop initial declarations are only allowed in C99 mode
[Error] ‘for‘ loop initial declarations are only allowed in C99 mode
325 0
[Error] ‘for‘ loop initial declarations are only allowed in C99 mode
如何处理错误消息Unable to install breakpoint due to missing line number attributes
如何处理错误消息Unable to install breakpoint due to missing line number attributes
185 0
如何处理错误消息Unable to install breakpoint due to missing line number attributes