V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
EchoChan
V2EX  ›  GCC

询问一个编译原理的问题: implicit declaration of function 'yyerror' is invalid in C99

  •  
  •   EchoChan · 2015-06-19 19:59:37 +08:00 · 13257 次点击
    这是一个创建于 3233 天前的主题,其中的信息可能已经有所发展或是发生改变。
    项目是根据 做的,源码在https://github.com/jengelsma/yacc-tutorial
    也就是两个文件,
    一个https://github.com/jengelsma/yacc-tutorial/blob/master/calc.l
    一个https://github.com/jengelsma/yacc-tutorial/blob/master/calc.y
    利用命令生成y.tab.c和y.tab.h以及lex.yy.c后,使用gcc lex.yy.c y.tab.c -o calc命令,出现了如下错误
    calc.l:11:8: warning: implicit declaration of function 'yyerror' is invalid in
    C99 [-Wimplicit-function-declaration]
    {ECHO; yyerror ("unexpected character");}
    ^
    1 warning generated.
    y.tab.c:1249:16: warning: implicit declaration of function 'yylex' is invalid in
    C99 [-Wimplicit-function-declaration]
    yychar = YYLEX;
    ^
    y.tab.c:605:16: note: expanded from macro 'YYLEX'
    # define YYLEX yylex ()
    ^
    calc.y:46:5: warning: implicit declaration of function 'islower' is invalid in
    C99 [-Wimplicit-function-declaration]
    if(islower(token)) {
    ^
    calc.y:48:12: warning: implicit declaration of function 'isupper' is invalid in
    C99 [-Wimplicit-function-declaration]
    } else if(isupper(token)) {
    ^
    3 warnings generated.

    Google了一圈,按照http://stackoverflow.com/questions/27220759/linker-error-yacc-on-mac
    和http://stackoverflow.com/questions/23717039/generating-a-compiler-from-lex-and-yacc-grammar的说法都没解决。请问这怎么解决?是不是因为os x 内置的GCC编译器只能生成C99风格的代码而造成的?
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2868 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:24 · PVG 23:24 · LAX 08:24 · JFK 11:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.