--- main.c +++ main.c @@ -1633,9 +1633,11 @@ if (!C_plus_plus && !reentrant) { outn ("extern int yylineno;"); - OUT_BEGIN_CODE (); - outn ("int yylineno = 1;"); - OUT_END_CODE (); + if (do_yylineno) { + OUT_BEGIN_CODE (); + outn ("int yylineno = 1;"); + OUT_END_CODE (); + } } if (C_plus_plus) { --- flex.skl +++ flex.skl @@ -80,6 +80,16 @@ m4preproc_define(`M4_GEN_PREFIX', ``m4_define(yy[[$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'') +%# don't use yylineno in non-reentrant scanners when %option yylineno not given +m4_ifdef( [[M4_YY_REENTRANT]],, + [[m4_ifdef( [[M4_YY_USE_LINENO]],, + [[ + m4_define( [[M4_YY_NO_GET_LINENO]], [[]]) + m4_define( [[M4_YY_NO_SET_LINENO]], [[]]) + ]]) + ]] +) + %if-c++-only /* The c++ scanner is a mess. The FlexLexer.h header file relies on the * following macro. This is required in order to pass the c++-multiple-scanners