lex yywrap() call

lex yywrap() call

Post by Mark L. Benne » Mon, 01 Nov 1993 13:08:41



: When I use the real lex (SunOS 4.1.3) on a machine I have an account on,
: lex.yy.c is made fine, but when I compile lex.yy.c locally, i get
: an error because the yywrap() function isn't defined on my machine.

Hi Chuck,

I had the exact same error.

It turns out that the -ll (to include the lex libraries) needs to
go at the end of the link command line in your make file.  When I
moved -ll to the end of the cc line, it suddenly worked.

FYI: I had a similar problem using the curses libraries.  Also, at
least with curses on this system, there was a difference between
the man pages and the library's functions.  It turns out that
one was bsd and the other was system 5.  I had to explicitly point
to the system 5 libraries.  To make matters worse, the position of
the -L option (to point to sys5) was important; if put in the
wrong place I still got the other libs.

This sure made things confusing!  I suspect there may be differences
between other sys5 and bsd libraries and the devil's in the makefile.

Mark

 
 
 

1. lex undefined reference to yywrap

I am working on the first, very basic example from the lex manpage;
the file ( I call it a ) has just 2 lines:

%%
username        printf( "%s", getlogin() );

I run it through flex with

lex a

which generates the file lex.yy.c

My understanding is that I should now be able to compile that file with

cc -ll lex.yy.c

to get an a.out executable

but instead I get:

/var/tmp/ccMVg4341.o: In function `yylex':
/var/tmp/ccMVg4341.o(.text+0x2ff): undefined reference to `yywrap'
/var/tmp/ccMVg4341.o: In function `input':
/var/tmp/ccMVg4341.o(.text+0xa27): undefined reference to `yywrap'

I have also tried it with:

cc -lfl lex.yy.c

with the same result.

Now, if I modify a slightly to:

%option noyywrap
%%
username        printf( "%s", getlogin() );

then it works fine, but my understanding is that the -ll or -lfl library
is supposed to contain a yywrap() which returns 1 as a default.

So, I guess I do not know if I am using this tool incorrectly or if there
is a bug here somewhere. I also wish there were a better reference about
using lex/flex somewhere on the net. I've looked and not found anything
very useful beyond the man pages.

Any assistance is appreciated.

2. Whither Linux for Macintosh?

3. LEX / YACC yywrap() question

4. DIP HELP WITH TIA

5. lex/yacc parsing: ending parse with yywrap?

6. Need help with firewall for Linux with ADSL connection

7. 2nd call -- lex help!!

8. pipe ufsdump thru pgp to tape

9. lex/yacc: yyparse() being executed without being called ?

10. lex unput() call

11. HELP: Calling lex w/string as input?

12. Lex maximum - Error when compiling with "lex"

13. yywrap()