Connecting Tech Pros Worldwide Help | Site Map

multiple definition problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 04:58 AM
Christian Christmann
Guest
 
Posts: n/a
Default multiple definition problem

Hi,

I'm using "flex" which is creating a file called lex.yy.c and this
C file is added to a library. In another directory I have to use flex for
another file and also add the second lex.yy.c to another library.
Hence, I need to include both libraries and while linking I get an
e.g. "multiple definition of `yyleng'" since yyleng is created in both
lexx.yy.c.

I can't change the variable name yyleng since it's
automatically created by flex. Any idea how to solve this problem?


Thank you

Chris

  #2  
Old July 23rd, 2005, 04:58 AM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: multiple definition problem

Christian Christmann wrote:[color=blue]
> I'm using "flex" which is creating a file called lex.yy.c and this
> C file is added to a library. In another directory I have to use flex for
> another file and also add the second lex.yy.c to another library.
> Hence, I need to include both libraries and while linking I get an
> e.g. "multiple definition of `yyleng'" since yyleng is created in both
> lexx.yy.c.
>
> I can't change the variable name yyleng since it's
> automatically created by flex. Any idea how to solve this problem?[/color]

If you're compiling them in C++, you could try wrapping those files in
two respective namespaces. If you're compiling them in C, then you should
ask in comp.lang.c. I know some folks actually filter those generated
modules (translation units) through a script that mangles the names just
to avoid the multiple definition problems.

Also, isn't there a lex/yacc newsgroup somewhere?

V
  #3  
Old July 23rd, 2005, 04:58 AM
Donovan Rebbechi
Guest
 
Posts: n/a
Default Re: multiple definition problem

On 2005-06-01, Christian Christmann <plfriko@yahoo.de> wrote:[color=blue]
> Hi,
>
> I'm using "flex" which is creating a file called lex.yy.c and this
> C file is added to a library. In another directory I have to use flex for
> another file and also add the second lex.yy.c to another library.
> Hence, I need to include both libraries and while linking I get an
> e.g. "multiple definition of `yyleng'" since yyleng is created in both
> lexx.yy.c.
>
> I can't change the variable name yyleng since it's
> automatically created by flex. Any idea how to solve this problem?[/color]

Did you try reading the documentation ? Take a look at the -P option.

Cheers,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.