[英]error compiling code - 'for' loop initial declarations are only allowed in C99 mode
I'm compiling gvmlib with make and this is showing the following error: 'for' loop initial declarations are only allowed in C99 mode.我正在用 make 编译 gvmlib,这显示以下错误:“for”循环初始声明仅在 C99 模式下允许。
I used gcc in the code with the --std=c99 and --std=gnu99 option in the code and fatal error appears: glib.h file or directory not found我在代码中使用了 gcc 和代码中的 --std=c99 和 --std=gnu99 选项,出现致命错误:glib.h file or directory not found
I installed glib 2.0 and it was working normally我安装了 glib 2.0,它工作正常
follow the part of the code that is giving error遵循给出错误的代码部分
static element_t find_child(element_t element, const gchar *name)
{
for (xmlNode *node = element->children; node; node = node->next)
if (xmlStrcmp(node->name, (const xmlChar *)name) == 0)
return node;
return NULL;
}
The compiler option to enable C99 (without changing anything else) is not --std=c99
, it is --std=gnu99
.启用 C99(不更改任何其他内容)的编译器选项不是
--std=c99
,而是--std=gnu99
。
If you use --std=c99
you both enable C99 and also disable GNU extensions that were turned on by the default setting (which is --std=gnu89
).如果您使用
--std=c99
,您将启用 C99 并禁用默认设置(即--std=gnu89
)打开的 GNU 扩展。
Of course by now you may want to use --std=gnu11
or --std=gnu18
.当然,现在您可能想要使用
--std=gnu11
或--std=gnu18
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.