compilation error of Lex.yy.c

S

sam_cit

Hi,
I just have the simple lex program
%%
. ECHO;
%%
int main()
{
yylex();
}

i did this, lex sample.l, which resulted in lex.yy.c then i tried to
complie the produced c file, on which i get the following error,

/tmp/ccYMo5KN.o: In function `yylex':
/tmp/ccYMo5KN.o(.text+0x353): undefined reference to `yywrap'
/tmp/ccYMo5KN.o: In function `input':
/tmp/ccYMo5KN.o(.text+0xb1a): undefined reference to `yywrap'
collect2: ld returned 1 exit status

Only way i have worked out is to have my own yywrap() function which
returns 1 always, but having said iam not able to understand the cause
of the problem, a simple lex program should work, like the following
%%
.. ECHO;
%%

but why isn't?
 
S

santosh

Hi,
I just have the simple lex program
%%
. ECHO;
%%
int main()
{
yylex();
}

i did this, lex sample.l, which resulted in lex.yy.c then i tried to
complie the produced c file, on which i get the following error,

/tmp/ccYMo5KN.o: In function `yylex':
/tmp/ccYMo5KN.o(.text+0x353): undefined reference to `yywrap'
/tmp/ccYMo5KN.o: In function `input':
/tmp/ccYMo5KN.o(.text+0xb1a): undefined reference to `yywrap'
collect2: ld returned 1 exit status

Only way i have worked out is to have my own yywrap() function which
returns 1 always, but having said iam not able to understand the cause
of the problem, a simple lex program should work, like the following
%%
. ECHO;
%%

but why isn't?

This is not a good place to ask this question, as it deals only with
standard C. Ask either in comp.compilers or a group specific to your
tools, which you've not specified.
 
R

Rod Pemberton

Hi,
I just have the simple lex program
%%
. ECHO;
%%
int main()
{
yylex();
}

i did this, lex sample.l, which resulted in lex.yy.c then i tried to
complie the produced c file, on which i get the following error,

/tmp/ccYMo5KN.o: In function `yylex':
/tmp/ccYMo5KN.o(.text+0x353): undefined reference to `yywrap'
/tmp/ccYMo5KN.o: In function `input':
/tmp/ccYMo5KN.o(.text+0xb1a): undefined reference to `yywrap'
collect2: ld returned 1 exit status

Only way i have worked out is to have my own yywrap() function which
returns 1 always, but having said iam not able to understand the cause
of the problem, a simple lex program should work, like the following
%%
. ECHO;
%%

but why isn't?

You're missing an '%option noyywrap'. You usually need a yywrap() function.
So, I'd recommend adding one for now:

int yywrap()
{
return(1);
}

http://www.gnu.org/software/flex/manual/html_mono/flex.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,226
Latest member
KristanTal

Latest Threads

Top