【发布时间】:2014-01-06 07:19:14
【问题描述】:
这是我的 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);}
^
【问题讨论】:
标签: gcc