Posted at

y.tab.cを実行したときのWarningへの対処


表示された Warning

y.tab.c:1223:16: warning: implicit declaration of function 'yylex' is invalid in C99 [-Wimplicit-function-declaration]

yychar = YYLEX;
^
y.tab.c:579:16: note: expanded from macro 'YYLEX'
# define YYLEX yylex ()
^
y.tab.c:1341:7: warning: implicit declaration of function 'yyerror' is invalid in C99 [-Wimplicit-function-declaration]
yyerror (YY_("syntax error"));
^
y.tab.c:1487:3: warning: implicit declaration of function 'yyerror' is invalid in C99 [-Wimplicit-function-declaration]
yyerror (YY_("memory exhausted"));
^


解決策

ファイル名.y に 以下を付け加える

%{

int yylex();
void yyerror(const char *s);
%}