使用gcc编译yacc文件时,关于格式不是字符串文字和无格式参数的警告

使用gcc编译yacc文件时,关于格式不是字符串文字和无格式参数的警告,gcc,Gcc,这是我的yacc文件的一部分,我已经用bison编译过了,当我想用gcc编译成可执行文件时,会得到一些警告 search2:WORD {fprintf(outFile_p,$1);} search2:WHITE {fprintf(outFile_p,$1);} |TAB {fprintf(outFile_p,"\t");} |EOL {counter=counter+1;fprintf(outFile_p,"\n");} |LB

这是我的yacc文件的一部分,我已经用bison编译过了,当我想用gcc编译成可执行文件时,会得到一些警告

search2:WORD    {fprintf(outFile_p,$1);}
search2:WHITE   {fprintf(outFile_p,$1);}
       |TAB     {fprintf(outFile_p,"\t");}
       |EOL     {counter=counter+1;fprintf(outFile_p,"\n");}
       |LBRAK   {fprintf(outFile_p,$1);}
       |RBRAK   {fprintf(outFile_p,$1);}
       |SIMICOL {fprintf(outFile_p,",");}
       |PERCENT {fprintf(outFile_p,"%%");}
       |PLUS    {fprintf(outFile_p,"+");}
       |ANY     {fprintf(outFile_p,$1);}
       |TCOM    {fprintf(outFile_p,"\"");}
       |MUL     {fprintf(outFile_p,$1);}
       |COM     {fprintf(outFile_p,";");}
       |LB      {fprintf(outFile_p,"[");}
       |RB      {fprintf(outFile_p,"]");}
那些带有“{fprintf(outFile_p,$1);}”的代码,当我想使用gcc编译时,会出现此警告

格式不是字符串文字,也没有格式参数

如果有人能帮我修复这个警告,或者我需要发布整个代码

警告如下所示

y.y:509:5: warning: format not a string literal and no format arguments [-Wformat-security]
 search2:WORD    {fprintf(outFile_p,$1);}
     ^
y.y:510:5: warning: format not a string literal and no format arguments [-Wformat-security]
 search2:WHITE   {fprintf(outFile_p,$1);}
     ^
y.y:513:5: warning: format not a string literal and no format arguments [-Wformat-security]
        |LBRAK   {fprintf(outFile_p,$1);}
     ^
y.y:514:5: warning: format not a string literal and no format arguments [-Wformat-security]
        |RBRAK   {fprintf(outFile_p,$1);}
     ^
y.y:518:5: warning: format not a string literal and no format arguments [-Wformat-security]
        |ANY     {fprintf(outFile_p,$1);}
     ^
y.y:520:5: warning: format not a string literal and no format arguments [-Wformat-security]
        |MUL     {fprintf(outFile_p,$1);}
     ^

以下是fprintf()函数的声明

int fprintf(FILE *stream, const char *format, ...)
您的代码缺少
$1

search2:WORD    {fprintf(outFile_p,"%s",$1);}
或者也可以使用FPUT-

search2:WORD    {fputs($1,outFile_p);}