Getting "implicit function declaration" fcloseall "is not valid in C99" when compiling in gnu99
Consider the following C code:
#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); } I use clang 2.8 to compile: clang -Wall -std=gnu99 -o <executable> <source.c>
And we get: implicit declaration of function 'fcloseall' is invalid in C99
This is true, but I am explicitly compiling gnu99 [which should support fcloseall ()], not c99. Although the code works, I do not like to have unresolved warnings when compiling. How can i solve this?
Edit : fixed type.
To enable custom extensions, when you include standard headers, you need to define an appropriate function check macro. In this case, _GNU_SOURCE should work.
#define _GNU_SOURCE #include <stdio.h> This is independent of -std=gnu99 , which allows language extensions, not library extensions.