undefined reference to `yywrap'




原因:flex版本>2.5.4时的一个不兼容动作


处理方法:


当调试出现 undefined reference to `yywrap'得时候解决办法。

%option noyywrap
或者是链接时候使用-lfl参数来使用fl库中得函数。
当然也可以自己添加一个yywrap函数。返回个1就行了。

 更多原因说明:

  • As previously noted by another poster this is a problem with the flex version on your system. If you use a flex with a higher version than 2.5.4 you're out of luck, unless you patch the sources. The reason for this is that the people developing flex had the "interesting" idea of changing the way the lexer parses the language file.

    The fix is to downgrade your flex or to patch cfg-lex.l with a %option field disabling yywarp. From the top of my head it should read:

    %option noyywrap Or you define the options as follows (I think):%{ prototype functionname(parameters);  %}


#define yywrap()  1

更好的办法是定义:
int yywrap() 

   return(1); 


关于yywrap更详细的信息可以参考unix的lex manual
http://www.scit.wlv.ac.uk/cgi-bin/mansec?1+lex

int yywrap(void)
           Called by yylex at  end-of-file;  the  default  yywrap
           always  will  return  1.  If  the application requires
           yylex to continue processing with  another  source  of
           input,  then  the  application  can include a function
           yywrap, which associates another file with the  exter-
           nal  variable  FILE  *yyin  and will return a value of
           zero.

或flex的参考手册(这个貌似更广泛一点):
http://www.gnu.org/software/flex/manual/html_mono/flex.html

When the scanner receives an end-of-file indication from YY_INPUT, it then checks the `yywrap()' function. If `yywrap()' returns false (zero), then it is assumed that the function has gone ahead and set up yyin to point to another input file, and scanning continues. If it returns true (non-zero), then the scanner terminates, returning 0 to its caller. Note that in either case, the start condition remains unchanged; it does notrevert to INITIAL.

If you do not supply your own version of `yywrap()', then you must either use `%option noyywrap' (in which case the scanner behaves as though `yywrap()' returned 1), or you must link with `-lfl' to obtain the default version of the routine, which always returns 1.



 

参考网址:http://stackoverflow.com/questions/1811125/undefined-reference-to-yywrap

  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值