如何编译C99模式下一个C项目? [英] How to compile a C project in C99 mode?

查看:156
本文介绍了如何编译C99模式下一个C项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了以下错误消息在编译C code:

I got the following error message while compiling the C code:

error: 'for' loop initial declarations are only allowed in C99 mode
note: use option -std=c99 or -std=gnu99 to compile your code

这是什么意思?

What does it mean?

如何解决?

推荐答案

您已经这样做了:

for (int i=0;i<10;i++) {

和你需要把它改成这样:

And you need to change it to this:

int i;
for (i=0;i<10;i++) {

或者,因为错误说:

使用选项-std = C99或-std = gnu99来编译code。

use option -std=c99 or -std=gnu99 to compile your code.

更新 从瑞安福克斯的答案复制的:

gcc -std=c99 foo.c -o foo

或者,如果您使用的是标准Makefile,把它添加到CFLAGS变量。

Or, if you're using a standard makefile, add it to the CFLAGS variable.

这篇关于如何编译C99模式下一个C项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆