在编译为gnu99时,获取“隐含的函数声明'fcloseall'在C99中无效”

时间:2011-01-13 12:50:05

标签: c c99 clang

考虑以下C代码:

#include <stdio.h>
#include <stdlib.h>

void fatal(const char* message){
 /*
  Prints a message and terminates the program.
  Closes all open i/o streams before exiting.
 */
 printf("%s\n", message);
 fcloseall();
 exit(EXIT_FAILURE);
}

我正在使用clang 2.8编译:{{1​​}}

得到:clang -Wall -std=gnu99 -o <executable> <source.c>

这是真的,但我明确地编译为gnu99 [应该支持fcloseall()],而不是c99。 虽然代码运行,但我不喜欢在编译时有未解决的警告。 我该如何解决这个问题?

修改:更正了提示。

2 个答案:

答案 0 :(得分:4)

要在包含标准标头时包含非标准扩展,您需要定义相应的功能测试宏。在这种情况下,_GNU_SOURCE应该有效。

#define _GNU_SOURCE
#include <stdio.h>

这与-std=gnu99无关,它可以启用语言扩展,而不是库扩展。

答案 1 :(得分:1)

DrawFunc

SELECT * WHERE enddate > '2017-01-13' AND startdate < '2017-01-22' 页面中
man

你必须定义宏_GNU_SOURCE是你的片段,还有fcloseall()标题。 #define _GNU_SOURCE #include <stdio.h> 是一个功能测试宏,用于创建可移植应用程序。

相关问题