Connecting Tech Pros Worldwide Help | Site Map

multiple definition problem

  #1  
Old July 23rd, 2005, 05:58 AM
Christian Christmann
Guest
 
Posts: n/a
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, 05:58 AM
Victor Bazarov
Guest
 
Posts: n/a

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, 05:58 AM
Donovan Rebbechi
Guest
 
Posts: n/a

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/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with multiple definition Antonio Rivas answers 3 February 1st, 2008 01:25 PM
Multiple definition error zfareed@mail.com answers 10 April 11th, 2007 11:55 PM
Template linking problem (multiple definition) Georg Teichtmeister answers 11 July 19th, 2005 06:10 PM
multiple definition Jochen Zeischka answers 2 July 19th, 2005 03:52 PM