Re: Removing GCC warnings from flex- and bison- generated C code

Charlie Zender <zender@uci.edu>
16 Jan 2004 22:38:52 -0500

          From comp.compilers

Related articles
Removing GCC warnings from flex- and bison- generated C code zender@uci.edu (Charlie Zender) (2004-01-09)
Re: Removing GCC warnings from flex- and bison- generated C code eggert@twinsun.com (Paul Eggert) (2004-01-12)
Re: Removing GCC warnings from flex- and bison- generated C code fjh@cs.mu.oz.au (Fergus Henderson) (2004-01-12)
Re: Removing GCC warnings from flex- and bison- generated C code zender@uci.edu (Charlie Zender) (2004-01-16)
| List of all articles for this month |
From: Charlie Zender <zender@uci.edu>
Newsgroups: comp.compilers
Date: 16 Jan 2004 22:38:52 -0500
Organization: University of California at Irvine
References: 04-01-045 04-01-065
Keywords: lex
Posted-Date: 16 Jan 2004 22:38:52 EST

Hi,


First, thanks to everyone who responded.


    >>ncap_yacc.c: In function `yyparse':
>>ncap_yacc.c:1216: warning: implicit declaration of function `yylex'


> You can avoid that one by explicitly declaring yylex() in the declaration
> section at the start of your .y file:


Yes, I'm now using YY_DECL in three places (my lexer gets called by
two different routines)


>>ncap_lex.l: In function `yylex':
>>ncap_lex.l:670: warning: implicit declaration of function `yy_flex_realloc'


> You can avoid that one by declaring yy_flex_realloc().


I tried that and yy_flex_realloc() is tricky. Adding


    int yy_flex_realloc(void *,size_t);


works on GNU/Linux but causes failures on IBM AIX xlC and
SGI IRIX cc. So prototyping these functions becomes platform/compiler
specific and, I think, would best be handled by flex itself.


>>ncap_lex.c: In function `yy_init_buffer':
>>ncap_lex.c:2595: warning: implicit declaration of function `fileno'


> That one can be fixed by compiling with -D_POSIX_SOURCE or including
> `#define _POSIX_SOURCE 1' in the declaration section of your .l file.


Thanks for the pointer, didn't know about POSIX_SOURCE, I'll try that.


The remaining functions are as yy_flex_realloc(). They either do or do
not get referenced by flex depending on the compiler/OS. So I'm
unable to include a prototyping hack in ncap_lex.l without many
compiler-specific tests which is extremely non-portable.


My guess is that if the flex maintainers would compile their test
lexers with -Werror -Wall -Wmissing-prototypes they would find the
same problems and could easily solve them.


Thanks,
Charlie


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.