使用lex 是有好几次的接触, 最近看bpf的代码里面用到了lex, 于是代码也看不懂了
1.l:
%%
.|
ECHO;
%%
$ lex 1.l
km@kwingmei:~/programming/c/lex$ gcc lex.yy.c
/tmp/ccehk4zT.o: In function `yylex':
lex.yy.c:(.text+0x38b): undefined reference to `yywrap'
/tmp/ccehk4zT.o: In function `input':
lex.yy.c:(.text+0xcd6): undefined reference to `yywrap'
collect2: error: ld returned 1 exit status
错误原因是
The scanner calls this function on end of file, so you can point it to another file and continue scanning its contents.
If you don't need this, use
%option noyywrap
or link with -lfl
to use the default yywrap() function in the library fl
.