Get rid of warning: implicit declaration of function ‘fileno’ in flex

Viewed 4573

I'm trying to get rid of a warning that gcc is throwing when I try to compile my bison and flex files:

: In function ‘yy_init_buffer’:
:1675: warning: implicit declaration of function ‘fileno’

The reason why I want to do this is because I'm trying to submit an assignment to the class I'm taking but I can only submit the "parser.y" and "scanner.l" files and it gets remotely compiled. The problem is: if there's a warning it gets (for some reason) considered an error and because I have no control over the compiler flags I can't make it disappear. I have seen some questions around the Internet with the same problem, but none of the solutions mentioned worked for me.

The compiler uses se following flags:

bison -d -o parser.c parser.y
flex -i -o scanner.c  scanner.l
gcc -std=c99 -pedantic -o test_parser *.c

I'm using a Mac OSX so when I compile it doesn't give me any warning, so I'm guessing it's something unique to linux distributions. Here's the header section of each file I have so you have an idea of what I've tried already:

scanner.l

#define _POSIX_SOURCE 1
//#define _GNU_SOURCE

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

parser.y

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

int yylex (void);
void yyerror (char const *);

Would really appreciate any kind of help here.

2 Answers
Related